#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_validate(char *, char *);
scalar_t__ chdir(char *);
int /*<<< orphan*/ do_work(int, int, int, int);
scalar_t__ parse_opt(int *, char ***, int, int *);
int /*<<< orphan*/ print_usage(char *);
int main(int argc, char **argv) {
  char *cmd = argv[0];
  int workers = 1;
  int files, bytes, mult;
  if (parse_opt(&argc, &argv, 4, &workers) == 0 &&
      (files = atoi_validate(argv[0], "# of files")) > 0 &&
      (bytes = atoi_validate(argv[1], "size of files")) > 0 &&
      (mult = atoi_validate(argv[2], "random multiplier")) > 0 &&
      chdir(argv[3]) == 0) {
    do_work(workers, files, bytes, mult);
  } else
    print_usage(cmd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
lea    -0x1c(%rbp),%rcx
call   1060 <parse_opt@plt>
cmp    $0x0,%rax
jne    1224 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe5a(%rip),%rsi
call   1030 <atoi_validate@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jle    1224 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe45(%rip),%rsi
call   1030 <atoi_validate@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jle    1224 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe33(%rip),%rsi
call   1030 <atoi_validate@plt>
mov    %eax,-0x28(%rbp)
cmp    $0x0,%eax
jle    1224 <main+0xd4>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1040 <chdir@plt>
cmp    $0x0,%rax
jne    1224 <main+0xd4>
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
call   1050 <do_work@plt>
jmp    122d <main+0xdd>
mov    -0x18(%rbp),%rdi
call   1070 <print_usage@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,0x14(%rsp)
mov    %rsi,0x8(%rsp)
mov    (%rsi),%rbx
movl   $0x1,0x10(%rsp)
lea    0x14(%rsp),%rdi
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rcx
mov    $0x4,%edx
call   1060 <parse_opt@plt>
test   %rax,%rax
je     11a1 <main+0x51>
mov    %rbx,%rdi
call   1070 <print_usage@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rax
mov    (%rax),%rdi
lea    0xe50(%rip),%rsi
call   1030 <atoi_validate@plt>
test   %eax,%eax
jle    118c <main+0x3c>
mov    %eax,%ebp
mov    0x8(%rsp),%rax
mov    0x8(%rax),%rdi
lea    0xe40(%rip),%rsi
call   1030 <atoi_validate@plt>
test   %eax,%eax
jle    118c <main+0x3c>
mov    %eax,%r14d
mov    0x8(%rsp),%rax
mov    0x10(%rax),%rdi
lea    0xe32(%rip),%rsi
call   1030 <atoi_validate@plt>
test   %eax,%eax
jle    118c <main+0x3c>
mov    %eax,%r15d
mov    0x8(%rsp),%rax
mov    0x18(%rax),%rdi
call   1040 <chdir@plt>
test   %rax,%rax
jne    118c <main+0x3c>
mov    0x10(%rsp),%edi
mov    %ebp,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
call   1050 <do_work@plt>
jmp    1194 <main+0x44>

LLVM IR (-O0):
@.str = [11 x i8] c"# of files\00"
@.str.1 = [14 x i8] c"size of files\00"
@.str.2 = [18 x i8] c"random multiplier\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
store i8* %13, i8** %6
store i32 1, i32* %7
%14 = call i64 @parse_opt(i32* %4, i8*** %5, i32 4, i32* %7)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %46
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @atoi_validate(i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %20, i32* %8
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %46
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 @atoi_validate(i8* %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
store i32 %26, i32* %9
%27 = icmp sgt i32 %26, 0
br i1 %27, label %28, label %46
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi_validate(i8* %31, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
store i32 %32, i32* %10
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %46
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = call i64 @chdir(i8* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %34
%41 = load i32, i32* %7
%42 = load i32, i32* %8
%43 = load i32, i32* %9
%44 = load i32, i32* %10
%45 = call i32 @do_work(i32 %41, i32 %42, i32 %43, i32 %44)
br label %49
46: ; preds = %34, %28, %22, %16, %2
%47 = load i8*, i8** %6
%48 = call i32 @print_usage(i8* %47)
br label %49
49: ; preds = %46, %40
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [11 x i8] c"# of files\00"
@.str.1 = [14 x i8] c"size of files\00"
@.str.2 = [18 x i8] c"random multiplier\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i8*, i8** %1
%7 = bitcast i32* %5 to i8*
store i32 1, i32* %5
%8 = call i64 @parse_opt(i32* %3, i8*** %4, i32 4, i32* %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %36
10: ; preds = %2
%11 = load i8**, i8*** %4
%12 = load i8*, i8** %11
%13 = call i32 @atoi_validate(i8* %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %36
15: ; preds = %10
%16 = load i8**, i8*** %4
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @atoi_validate(i8* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %36
21: ; preds = %15
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @atoi_validate(i8* %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp sgt i32 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %21
%28 = load i8**, i8*** %4
%29 = getelementptr inbounds i8*, i8** %28, i64 3
%30 = load i8*, i8** %29
%31 = call i64 @chdir(i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %27
%34 = load i32, i32* %5
%35 = call i32 @do_work(i32 %34, i32 %13, i32 %19, i32 %25)
br label %38
36: ; preds = %27, %21, %15, %10, %2
%37 = call i32 @print_usage(i8* %6)
br label %38
38: ; preds = %36, %33
ret i32 0
}