#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) {
  char *state;
  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    $0x20,%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,-0x14(%rbp)
cmpl   $0x64,-0x14(%rbp)
jge    11e4 <handle_endless+0x84>
cmpl   $0x0,-0x14(%rbp)
jg     11f9 <handle_endless+0x99>
mov    -0x8(%rbp),%rsi
lea    0xe20(%rip),%rdi
call   1040 <printf@plt>
jmp    1212 <handle_endless+0xb2>
mov    -0x14(%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    $0x20,%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    $0xffffff9c,%ecx
ja     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 i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %35
7: ; preds = %1
%8 = load i8*, i8** %2
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %13, label %11
11: ; preds = %7
%12 = call i32 @endless_enable(i32 1)
br label %34
13: ; preds = %7
%14 = load i8*, i8** %2
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 @endless_enable(i32 0)
br label %33
19: ; preds = %13
%20 = load i8*, i8** %2
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = icmp sge i32 %22, 100
br i1 %23, label %27, label %24
24: ; preds = %19
%25 = load i32, i32* %4
%26 = icmp sle i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %24, %19
%28 = load i8*, i8** %2
%29 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %37
30: ; preds = %24
%31 = load i32, i32* %4
%32 = call i32 @set_endless_percentage(i32 %31)
br label %33
33: ; preds = %30, %17
br label %34
34: ; preds = %33, %11
br label %35
35: ; preds = %34, %1
%36 = call i32 (...) @print_endless()
br label %37
37: ; preds = %35, %27
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 %17, label %19
17: ; preds = %13
%18 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %23
19: ; preds = %13
%20 = tail call i32 @set_endless_percentage(i32 %14)
br label %21
21: ; preds = %11, %19, %6, %1
%22 = tail call i32 (...) @print_endless()
br label %23
23: ; preds = %17, %21
ret void
}