#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 generate_data(long long);
int /*<<< orphan*/ print_usage(char **);
scalar_t__ strcmp(char *, char *);
long long strtol(char *, int /*<<< orphan*/ *, int);
int verify_data(long long);
int main(int argc, char **argv) {
  long long num_nums;
  if (argc != 3) {
    print_usage(argv);
    return -1;
  }
  num_nums = strtol(argv[2], NULL, 10);
  if (num_nums <= 0) {
    print_usage(argv);
    return -1;
  }
  if (strcmp(argv[1], "read") == 0) {
    return verify_data(num_nums);
  } else if (strcmp(argv[1], "write") == 0) {
    return generate_data(num_nums);
  } else {
    print_usage(argv);
  }
  return -1;
}


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)
cmpl   $0x3,-0x8(%rbp)
je     1185 <main+0x35>
mov    -0x10(%rbp),%rdi
call   1070 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1232 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jg     11bf <main+0x6f>
mov    -0x10(%rbp),%rdi
call   1070 <print_usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1232 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe32(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ee <main+0x9e>
mov    -0x18(%rbp),%rdi
call   1060 <verify_data@plt>
mov    %eax,-0x4(%rbp)
jmp    1232 <main+0xe2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe08(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    121d <main+0xcd>
mov    -0x18(%rbp),%rdi
call   1050 <generate_data@plt>
mov    %eax,-0x4(%rbp)
jmp    1232 <main+0xe2>
mov    -0x10(%rbp),%rdi
call   1070 <print_usage@plt>
jmp    122b <main+0xdb>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x3,%edi
jne    119e <main+0x4e>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
test   %rax,%rax
jle    119e <main+0x4e>
mov    %rax,%r14
mov    0x8(%rbx),%rdi
lea    0xe81(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11b3 <main+0x63>
mov    0x8(%rbx),%rdi
lea    0xe71(%rip),%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c2 <main+0x72>
mov    %rbx,%rdi
call   1070 <print_usage@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <verify_data@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <generate_data@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"read\00"
@.str.1 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 3
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = call i32 @print_usage(i8** %10)
store i32 -1, i32* %3
br label %45
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 2
%15 = load i8*, i8** %14
%16 = call i64 @strtol(i8* %15, i32* null, i32 10)
store i64 %16, i64* %6
%17 = load i64, i64* %6
%18 = icmp sle i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i8**, i8*** %5
%21 = call i32 @print_usage(i8** %20)
store i32 -1, i32* %3
br label %45
22: ; preds = %12
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %22
%29 = load i64, i64* %6
%30 = call i32 @verify_data(i64 %29)
store i32 %30, i32* %3
br label %45
31: ; preds = %22
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i64 @strcmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = load i64, i64* %6
%39 = call i32 @generate_data(i64 %38)
store i32 %39, i32* %3
br label %45
40: ; preds = %31
%41 = load i8**, i8*** %5
%42 = call i32 @print_usage(i8** %41)
br label %43
43: ; preds = %40
br label %44
44: ; preds = %43
store i32 -1, i32* %3
br label %45
45: ; preds = %44, %37, %28, %19, %9
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [5 x i8] c"read\00"
@.str.1 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @print_usage(i8** %1)
br label %28
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i64 @strtol(i8* nocapture %8, i32* null, i32 10)
%10 = icmp slt i64 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @print_usage(i8** %1)
br label %28
13: ; preds = %6
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 @verify_data(i64 %9)
br label %28
20: ; preds = %13
%21 = load i8*, i8** %14
%22 = tail call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @generate_data(i64 %9)
br label %28
26: ; preds = %20
%27 = tail call i32 @print_usage(i8** %1)
br label %28
28: ; preds = %26, %24, %18, %11, %4
%29 = phi i32 [ -1, %4 ], [ -1, %11 ], [ %19, %18 ], [ %25, %24 ], [ -1, %26 ]
ret i32 %29
}