#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 INT_MAX;
int INT_MIN;
int /*<<< orphan*/ clearRegisters_setsallzeros(int);
int getopt(int, char **, char *);
int /*<<< orphan*/ log_init(int, int /*<<< orphan*/);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ setRegister_badreg_notstorevalue(int, int);
int /*<<< orphan*/ setRegister_validinput_storesvalue(int, int);
int main(int argc, char **argv) {
  int ch;
  while ((ch = getopt(argc, argv, "d")) != -1) {
    switch (ch) {
    case 'd':
      log_init(2, 0);
      break;
    default:
      printf("bad option... exiting\n");
      return 1;
    }
  }
  argc -= optind;
  argv += optind;
  if (argc > 0) {
    printf("too many args... exiting\n");
    return 1;
  }
  printf("Test: clearRegisters_setsallzeros\n\n");
  clearRegisters_setsallzeros(0x0);
  clearRegisters_setsallzeros(0x7);
  printf("\n");
  printf("Test: setRegister_badreg_notstorevalue\n\n");
  setRegister_badreg_notstorevalue(9, 5);
  setRegister_badreg_notstorevalue(0xf, 127);
  setRegister_badreg_notstorevalue(-1, 16);
  setRegister_badreg_notstorevalue(INT_MIN, 200);
  setRegister_badreg_notstorevalue(INT_MAX, 200);
  printf("\n");
  printf("Test: setRegister_validinput_storesvalue\n\n");
  setRegister_validinput_storesvalue(0x0, 5);
  setRegister_validinput_storesvalue(0x2, 127);
  setRegister_validinput_storesvalue(0x6, 16);
  setRegister_validinput_storesvalue(0x4, INT_MAX);
  printf("\n");
  printf("Test: clearMemory_setsallzeros\n\n");
  clearRegisters_setsallzeros(0x0);
  clearRegisters_setsallzeros(0x7);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7c(%rip),%rdx
call   1080 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     11d4 <main+0x74>
mov    -0x14(%rbp),%eax
sub    $0x64,%eax
jne    11b7 <main+0x57>
jmp    11a6 <main+0x46>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <log_init@plt>
jmp    11cf <main+0x6f>
lea    0xe44(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1326 <main+0x1c6>
jmp    1176 <main+0x16>
mov    0x2dfd(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2de9(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1220 <main+0xc0>
lea    0xe0a(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1326 <main+0x1c6>
lea    0xe0c(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <clearRegisters_setsallzeros@plt>
mov    $0x7,%edi
call   1070 <clearRegisters_setsallzeros@plt>
lea    0xe3a(%rip),%rdi
call   1050 <printf@plt>
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    $0x9,%edi
mov    $0x5,%esi
call   1060 <setRegister_badreg_notstorevalue@plt>
mov    $0xf,%edi
mov    $0x7f,%esi
call   1060 <setRegister_badreg_notstorevalue@plt>
mov    $0xffffffff,%edi
mov    $0x10,%esi
call   1060 <setRegister_badreg_notstorevalue@plt>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
mov    $0xc8,%esi
call   1060 <setRegister_badreg_notstorevalue@plt>
mov    0x2d4c(%rip),%rax
mov    (%rax),%edi
mov    $0xc8,%esi
call   1060 <setRegister_badreg_notstorevalue@plt>
lea    0xdcf(%rip),%rdi
call   1050 <printf@plt>
lea    0xdc5(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
mov    $0x5,%esi
call   1040 <setRegister_validinput_storesvalue@plt>
mov    $0x2,%edi
mov    $0x7f,%esi
call   1040 <setRegister_validinput_storesvalue@plt>
mov    $0x6,%edi
mov    $0x10,%esi
call   1040 <setRegister_validinput_storesvalue@plt>
mov    0x2cf7(%rip),%rax
mov    (%rax),%esi
mov    $0x4,%edi
call   1040 <setRegister_validinput_storesvalue@plt>
lea    0xd7a(%rip),%rdi
call   1050 <printf@plt>
lea    0xd9b(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <clearRegisters_setsallzeros@plt>
mov    $0x7,%edi
call   1070 <clearRegisters_setsallzeros@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe80(%rip),%r14
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1090 <getopt@plt>
cmp    $0x64,%eax
jne    11a0 <main+0x30>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <log_init@plt>
jmp    1180 <main+0x10>
cmp    $0xffffffff,%eax
jne    11bb <main+0x4b>
mov    0x2e2c(%rip),%rax
sub    (%rax),%ebp
test   %ebp,%ebp
jle    11d1 <main+0x61>
lea    0xede(%rip),%rdi
jmp    11c2 <main+0x52>
lea    0xeee(%rip),%rdi
call   1050 <puts@plt>
mov    $0x1,%ebx
jmp    12ce <main+0x15e>
lea    0xe2a(%rip),%rdi
call   1050 <puts@plt>
xor    %ebx,%ebx
xor    %edi,%edi
call   1080 <clearRegisters_setsallzeros@plt>
mov    $0x7,%edi
call   1080 <clearRegisters_setsallzeros@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe24(%rip),%rdi
call   1050 <puts@plt>
mov    $0x9,%edi
mov    $0x5,%esi
call   1070 <setRegister_badreg_notstorevalue@plt>
mov    $0xf,%edi
mov    $0x7f,%esi
call   1070 <setRegister_badreg_notstorevalue@plt>
mov    $0xffffffff,%edi
mov    $0x10,%esi
call   1070 <setRegister_badreg_notstorevalue@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
mov    $0xc8,%esi
call   1070 <setRegister_badreg_notstorevalue@plt>
mov    0x2d9b(%rip),%rbp
mov    0x0(%rbp),%edi
mov    $0xc8,%esi
call   1070 <setRegister_badreg_notstorevalue@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xde2(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
mov    $0x5,%esi
call   1060 <setRegister_validinput_storesvalue@plt>
mov    $0x2,%edi
mov    $0x7f,%esi
call   1060 <setRegister_validinput_storesvalue@plt>
mov    $0x6,%edi
mov    $0x10,%esi
call   1060 <setRegister_validinput_storesvalue@plt>
mov    0x0(%rbp),%esi
mov    $0x4,%edi
call   1060 <setRegister_validinput_storesvalue@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xdbf(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1080 <clearRegisters_setsallzeros@plt>
mov    $0x7,%edi
call   1080 <clearRegisters_setsallzeros@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"d\00"
@.str.1 = [23 x i8] c"bad option... exiting\0A\00"
@optind = global i64 0
@.str.2 = [26 x i8] c"too many args... exiting\0A\00"
@.str.3 = [36 x i8] c"Test: clearRegisters_setsallzeros\0A\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [41 x i8] c"Test: setRegister_badreg_notstorevalue\0A\0A\00"
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@.str.6 = [43 x i8] c"Test: setRegister_validinput_storesvalue\0A\0A\00"
@.str.7 = [33 x i8] c"Test: clearMemory_setsallzeros\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %18, %2
%8 = load i32, i32* %4
%9 = load i8**, i8*** %5
%10 = call i32 @getopt(i32 %8, i8** %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %10, i32* %6
%11 = icmp ne i32 %10, -1
br i1 %11, label %12, label %19
12: ; preds = %7
%13 = load i32, i32* %6
switch i32 %13, label %16 [
i32 100, label %14
]
14: ; preds = %12
%15 = call i32 @log_init(i32 2, i32 0)
br label %18
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %56
18: ; preds = %14
br label %7
19: ; preds = %7
%20 = load i64, i64* @optind
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = sub nsw i64 %22, %20
%24 = trunc i64 %23 to i32
store i32 %24, i32* %4
%25 = load i64, i64* @optind
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 %25
store i8** %27, i8*** %5
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %19
%31 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %56
32: ; preds = %19
%33 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @clearRegisters_setsallzeros(i32 0)
%35 = call i32 @clearRegisters_setsallzeros(i32 7)
%36 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%37 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 @setRegister_badreg_notstorevalue(i32 9, i32 5)
%39 = call i32 @setRegister_badreg_notstorevalue(i32 15, i32 127)
%40 = call i32 @setRegister_badreg_notstorevalue(i32 -1, i32 16)
%41 = load i32, i32* @INT_MIN
%42 = call i32 @setRegister_badreg_notstorevalue(i32 %41, i32 200)
%43 = load i32, i32* @INT_MAX
%44 = call i32 @setRegister_badreg_notstorevalue(i32 %43, i32 200)
%45 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%46 = call i32 @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.6, i64 0, i64 0))
%47 = call i32 @setRegister_validinput_storesvalue(i32 0, i32 5)
%48 = call i32 @setRegister_validinput_storesvalue(i32 2, i32 127)
%49 = call i32 @setRegister_validinput_storesvalue(i32 6, i32 16)
%50 = load i32, i32* @INT_MAX
%51 = call i32 @setRegister_validinput_storesvalue(i32 4, i32 %50)
%52 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%53 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%54 = call i32 @clearRegisters_setsallzeros(i32 0)
%55 = call i32 @clearRegisters_setsallzeros(i32 7)
br label %56
56: ; preds = %32, %30, %16
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
@.str = [2 x i8] c"d\00"
@optind = global i64 0
@INT_MIN = global i32 0
@INT_MAX = global i32 0
@str = [35 x i8] c"Test: clearRegisters_setsallzeros\0A\00"
@str.8 = [40 x i8] c"Test: setRegister_badreg_notstorevalue\0A\00"
@str.9 = [42 x i8] c"Test: setRegister_validinput_storesvalue\0A\00"
@str.10 = [32 x i8] c"Test: clearMemory_setsallzeros\0A\00"
@str.11 = [25 x i8] c"too many args... exiting\00"
@str.12 = [22 x i8] c"bad option... exiting\00"
define i32 @main(i32 %0, i8** %1) {
br label %3
3: ; preds = %5, %2
%4 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %4, label %7 [
i32 -1, label %9
i32 100, label %5
]
5: ; preds = %3
%6 = tail call i32 @log_init(i32 2, i32 0)
br label %3
7: ; preds = %3
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.12, i64 0, i64 0))
br label %40
9: ; preds = %3
%10 = load i64, i64* @optind
%11 = trunc i64 %10 to i32
%12 = sub i32 %0, %11
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.11, i64 0, i64 0))
br label %40
16: ; preds = %9
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%18 = tail call i32 @clearRegisters_setsallzeros(i32 0)
%19 = tail call i32 @clearRegisters_setsallzeros(i32 7)
%20 = tail call i32 @putchar(i32 10)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.8, i64 0, i64 0))
%22 = tail call i32 @setRegister_badreg_notstorevalue(i32 9, i32 5)
%23 = tail call i32 @setRegister_badreg_notstorevalue(i32 15, i32 127)
%24 = tail call i32 @setRegister_badreg_notstorevalue(i32 -1, i32 16)
%25 = load i32, i32* @INT_MIN
%26 = tail call i32 @setRegister_badreg_notstorevalue(i32 %25, i32 200)
%27 = load i32, i32* @INT_MAX
%28 = tail call i32 @setRegister_badreg_notstorevalue(i32 %27, i32 200)
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.9, i64 0, i64 0))
%31 = tail call i32 @setRegister_validinput_storesvalue(i32 0, i32 5)
%32 = tail call i32 @setRegister_validinput_storesvalue(i32 2, i32 127)
%33 = tail call i32 @setRegister_validinput_storesvalue(i32 6, i32 16)
%34 = load i32, i32* @INT_MAX
%35 = tail call i32 @setRegister_validinput_storesvalue(i32 4, i32 %34)
%36 = tail call i32 @putchar(i32 10)
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.10, i64 0, i64 0))
%38 = tail call i32 @clearRegisters_setsallzeros(i32 0)
%39 = tail call i32 @clearRegisters_setsallzeros(i32 7)
br label %40
40: ; preds = %16, %14, %7
%41 = phi i32 [ 1, %7 ], [ 1, %14 ], [ 0, %16 ]
ret i32 %41
}