#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ endless_enable(int);
int /*<<< orphan*/ print_endless();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ set_endless_percentage(int);
int /*<<< orphan*/ strcmp(char *, char *);
void handle_endless(char *arg) {
  if (arg) {
    int percentage;
    if (!strcmp(arg, "enable")) {
      endless_enable(1);
    } else if (!strcmp(arg, "disable")) {
      endless_enable(0);
    } else {
      percentage = atoi(arg);
      if ((percentage >= 100) || (percentage <= 0)) {
        printf("invalid enless argument: %s\n", arg);
        return;
      }
      set_endless_percentage(percentage);
    }
  }
  print_endless();
}


x86 assembly (clang, -O0):
<handle_endless>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     120b <handle_endless+0xab>
mov    -0x8(%rbp),%rdi
lea    0xe7e(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    119f <handle_endless+0x3f>
mov    $0x1,%edi
call   1070 <endless_enable@plt>
jmp    1206 <handle_endless+0xa6>
mov    -0x8(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11c4 <handle_endless+0x64>
xor    %edi,%edi
call   1070 <endless_enable@plt>
jmp    1201 <handle_endless+0xa1>
mov    -0x8(%rbp),%rdi
call   1080 <atoi@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x64,-0xc(%rbp)
jge    11e4 <handle_endless+0x84>
cmpl   $0x0,-0xc(%rbp)
jg     11f9 <handle_endless+0x99>
mov    -0x8(%rbp),%rsi
lea    0xe20(%rip),%rdi
call   1040 <printf@plt>
jmp    1212 <handle_endless+0xb2>
mov    -0xc(%rbp),%edi
call   1050 <set_endless_percentage@plt>
jmp    1206 <handle_endless+0xa6>
jmp    120b <handle_endless+0xab>
mov    $0x0,%al
call   1030 <print_endless@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_endless>:
push   %rbx
test   %rdi,%rdi
je     11c8 <handle_endless+0x68>
mov    %rdi,%rbx
lea    0xe90(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11ac <handle_endless+0x4c>
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11b8 <handle_endless+0x58>
mov    %rbx,%rdi
call   1080 <atoi@plt>
lea    -0x64(%rax),%ecx
cmp    $0xffffff9d,%ecx
jae    11c1 <handle_endless+0x61>
lea    0xe6c(%rip),%rdi
mov    %rbx,%rsi
pop    %rbx
jmp    1040 <printf@plt>
mov    $0x1,%edi
call   1070 <endless_enable@plt>
jmp    11c8 <handle_endless+0x68>
xor    %edi,%edi
call   1070 <endless_enable@plt>
jmp    11c8 <handle_endless+0x68>
mov    %eax,%edi
call   1050 <set_endless_percentage@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <print_endless@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"enable\00"
@.str.1 = [8 x i8] c"disable\00"
@.str.2 = [29 x i8] c"invalid enless argument: %s\0A\00"
define void @handle_endless(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %6, label %34
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i32 @strcmp(i8* %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = call i32 @endless_enable(i32 1)
br label %33
12: ; preds = %6
%13 = load i8*, i8** %2
%14 = call i32 @strcmp(i8* %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %12
%17 = call i32 @endless_enable(i32 0)
br label %32
18: ; preds = %12
%19 = load i8*, i8** %2
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = icmp sge i32 %21, 100
br i1 %22, label %26, label %23
23: ; preds = %18
%24 = load i32, i32* %3
%25 = icmp sle i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %23, %18
%27 = load i8*, i8** %2
%28 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %27)
br label %36
29: ; preds = %23
%30 = load i32, i32* %3
%31 = call i32 @set_endless_percentage(i32 %30)
br label %32
32: ; preds = %29, %16
br label %33
33: ; preds = %32, %10
br label %34
34: ; preds = %33, %1
%35 = call i32 (...) @print_endless()
br label %36
36: ; preds = %34, %26
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"enable\00"
@.str.1 = [8 x i8] c"disable\00"
@.str.2 = [29 x i8] c"invalid enless argument: %s\0A\00"
define void @handle_endless(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @endless_enable(i32 1)
br label %21
8: ; preds = %3
%9 = tail call i32 @strcmp(i8* %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %8
%12 = tail call i32 @endless_enable(i32 0)
br label %21
13: ; preds = %8
%14 = tail call i32 @atoi(i8* %0)
%15 = add i32 %14, -100
%16 = icmp ult i32 %15, -99
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = tail call i32 @set_endless_percentage(i32 %14)
br label %21
19: ; preds = %13
%20 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %23
21: ; preds = %6, %17, %11, %1
%22 = tail call i32 (...) @print_endless()
br label %23
23: ; preds = %19, %21
ret void
}