#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 */
scalar_t__ feof(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ rax(char *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  int i;
  char buf[1024];
  if (argc == 1) {
    while (!feof(stdin)) {
      fgets(buf, 1000, stdin);
      buf[strlen(buf) - 1] = '\0';
      if (feof(stdin))
        break;
      rax(buf);
    }
    return 0;
  }
  if (!strcmp(argv[1], "-h"))
    printf("Usage: rax [-] | [-s] [-e] [int|0x|Fx|.f|.o] [...]\n");
  for (i = 1; i < argc; i++)
    rax(argv[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1219 <main+0xb9>
jmp    1188 <main+0x28>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11ac <main+0x4c>
jmp    120d <main+0xad>
lea    -0x420(%rbp),%rdi
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
mov    $0x3e8,%esi
call   1050 <fgets@plt>
lea    -0x420(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x420(%rbp,%rax,1)
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1070 <feof@plt>
cmp    $0x0,%rax
je     11fc <main+0x9c>
jmp    120d <main+0xad>
lea    -0x420(%rbp),%rdi
call   1080 <rax@plt>
jmp    1188 <main+0x28>
movl   $0x0,-0x4(%rbp)
jmp    127b <main+0x11b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdd8(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    1242 <main+0xe2>
lea    0xdc6(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1274 <main+0x114>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1080 <rax@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1249 <main+0xe9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
cmp    $0x1,%edi
jne    11d3 <main+0x73>
mov    0x2e71(%rip),%rbp
mov    0x0(%rbp),%edi
call   1070 <feof@plt>
test   %rax,%rax
jne    1222 <main+0xc2>
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1050 <fgets@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%rbx,1)
mov    0x0(%rbp),%edi
call   1070 <feof@plt>
test   %rax,%rax
jne    1222 <main+0xc2>
mov    %rbx,%rdi
call   1080 <rax@plt>
mov    0x0(%rbp),%edi
call   1070 <feof@plt>
test   %rax,%rax
je     1190 <main+0x30>
jmp    1222 <main+0xc2>
mov    %rsi,%r14
mov    %edi,%ebp
mov    0x8(%rsi),%rdi
lea    0xe1d(%rip),%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
je     11f3 <main+0x93>
cmp    $0x2,%ebp
jge    1204 <main+0xa4>
jmp    1222 <main+0xc2>
lea    0xe09(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x2,%ebp
jl     1222 <main+0xc2>
mov    %ebp,%ebp
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1080 <rax@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1210 <main+0xb0>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdin = global i32 0
@.str = [3 x i8] c"-h\00"
@.str.1 = [52 x i8] c"Usage: rax [-] | [-s] [-e] [int|0x|Fx|.f|.o] [...]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %33
10: ; preds = %2
br label %11
11: ; preds = %29, %10
%12 = load i32, i32* @stdin
%13 = call i64 @feof(i32 %12)
%14 = icmp ne i64 %13, 0
%15 = xor i1 %14, true
br i1 %15, label %16, label %32
16: ; preds = %11
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%18 = load i32, i32* @stdin
%19 = call i32 @fgets(i8* %17, i32 1000, i32 %18)
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = sub nsw i32 %21, 1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 %23
store i8 0, i8* %24
%25 = load i32, i32* @stdin
%26 = call i64 @feof(i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %16
br label %32
29: ; preds = %16
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%31 = call i32 @rax(i8* %30)
br label %11
32: ; preds = %28, %11
store i32 0, i32* %3
br label %57
33: ; preds = %2
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @strcmp(i8* %36, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%38 = icmp ne i32 %37, 0
br i1 %38, label %41, label %39
39: ; preds = %33
%40 = call i32 @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %39, %33
store i32 1, i32* %6
br label %42
42: ; preds = %53, %41
%43 = load i32, i32* %6
%44 = load i32, i32* %4
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %56
46: ; preds = %42
%47 = load i8**, i8*** %5
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
%52 = call i32 @rax(i8* %51)
br label %53
53: ; preds = %46
%54 = load i32, i32* %6
%55 = add nsw i32 %54, 1
store i32 %55, i32* %6
br label %42
56: ; preds = %42
store i32 0, i32* %3
br label %57
57: ; preds = %56, %32
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@stdin = global i32 0
@.str = [3 x i8] c"-h\00"
@str = [51 x i8] c"Usage: rax [-] | [-s] [-e] [int|0x|Fx|.f|.o] [...]\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp eq i32 %0, 1
br i1 %5, label %6, label %25
6: ; preds = %2
%7 = load i32, i32* @stdin
%8 = call i64 @feof(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %43
10: ; preds = %6, %20
%11 = load i32, i32* @stdin
%12 = call i32 @fgets(i8* %4, i32 1000, i32 %11)
%13 = call i32 @strlen(i8* %4)
%14 = add nsw i32 %13, -1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 %15
store i8 0, i8* %16
%17 = load i32, i32* @stdin
%18 = call i64 @feof(i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %43
20: ; preds = %10
%21 = call i32 @rax(i8* %4)
%22 = load i32, i32* @stdin
%23 = call i64 @feof(i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %10, label %43
25: ; preds = %2
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = tail call i32 @strcmp(i8* dereferenceable(1) %27, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %25
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
br label %32
32: ; preds = %30, %25
%33 = icmp sgt i32 %0, 1
br i1 %33, label %34, label %43
34: ; preds = %32
%35 = zext i32 %0 to i64
br label %36
36: ; preds = %34, %36
%37 = phi i64 [ 1, %34 ], [ %41, %36 ]
%38 = getelementptr inbounds i8*, i8** %1, i64 %37
%39 = load i8*, i8** %38
%40 = tail call i32 @rax(i8* %39)
%41 = add nuw nsw i64 %37, 1
%42 = icmp eq i64 %41, %35
br i1 %42, label %43, label %36
43: ; preds = %36, %10, %20, %32, %6
ret i32 0
}