#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 */
typedef int /*<<< orphan*/ tdir;

/* Variables and functions */
int EXIT_SUCCESS;
int PATH_MAX;
int dump_empty_buf(char *);
int dump_small_buf(char *);
int fill_entire_buf(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int get_tempdir(char *, int, int);
int register_tempdir_for_cleanup(char *);
int /*<<< orphan*/ stderr;
int test_dump_all(char *);
int test_tokenizer();
int main(void) {
  char tdir[PATH_MAX];
  do {
    int __my_ret__ = get_tempdir(tdir, sizeof(tdir), 0775);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 310,
              "get_tempdir(tdir, sizeof(tdir), 0775)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = register_tempdir_for_cleanup(tdir);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 311,
              "register_tempdir_for_cleanup(tdir)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = dump_empty_buf(tdir);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 313, "dump_empty_buf(tdir)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = dump_small_buf(tdir);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 314, "dump_small_buf(tdir)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = fill_entire_buf(tdir);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 315, "fill_entire_buf(tdir)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = test_dump_all(tdir);
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 316, "test_dump_all(tdir)");
      return __my_ret__;
    }
  } while (0);
  ;
  do {
    int __my_ret__ = test_tokenizer();
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 317, "test_tokenizer()");
      return __my_ret__;
    }
  } while (0);
  ;
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%esi
mov    $0x1fd,%edx
call   1050 <get_tempdir@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1213 <main+0x93>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
mov    $0x136,%edx
lea    0xe1b(%rip),%rcx
call   1040 <fprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    143e <main+0x2be>
jmp    1218 <main+0x98>
jmp    121d <main+0x9d>
jmp    1222 <main+0xa2>
mov    -0x40(%rbp),%rdi
call   1030 <register_tempdir_for_cleanup@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     126b <main+0xeb>
mov    0x2d99(%rip),%rax
mov    (%rax),%edi
lea    0xdb8(%rip),%rsi
mov    $0x137,%edx
lea    0xde9(%rip),%rcx
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    143e <main+0x2be>
jmp    1270 <main+0xf0>
jmp    1275 <main+0xf5>
jmp    127a <main+0xfa>
mov    -0x40(%rbp),%rdi
call   1070 <dump_empty_buf@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
je     12c3 <main+0x143>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xd60(%rip),%rsi
mov    $0x139,%edx
lea    0xdb4(%rip),%rcx
call   1040 <fprintf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    143e <main+0x2be>
jmp    12c8 <main+0x148>
jmp    12cd <main+0x14d>
jmp    12d2 <main+0x152>
mov    -0x40(%rbp),%rdi
call   10a0 <dump_small_buf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
je     131b <main+0x19b>
mov    0x2ce9(%rip),%rax
mov    (%rax),%edi
lea    0xd08(%rip),%rsi
mov    $0x13a,%edx
lea    0xd71(%rip),%rcx
call   1040 <fprintf@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    143e <main+0x2be>
jmp    1320 <main+0x1a0>
jmp    1325 <main+0x1a5>
jmp    132a <main+0x1aa>
mov    -0x40(%rbp),%rdi
call   1090 <fill_entire_buf@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
je     1373 <main+0x1f3>
mov    0x2c91(%rip),%rax
mov    (%rax),%edi
lea    0xcb0(%rip),%rsi
mov    $0x13b,%edx
lea    0xd2e(%rip),%rcx
call   1040 <fprintf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    143e <main+0x2be>
jmp    1378 <main+0x1f8>
jmp    137d <main+0x1fd>
jmp    1382 <main+0x202>
mov    -0x40(%rbp),%rdi
call   1060 <test_dump_all@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     13cb <main+0x24b>
mov    0x2c39(%rip),%rax
mov    (%rax),%edi
lea    0xc58(%rip),%rsi
mov    $0x13c,%edx
lea    0xcec(%rip),%rcx
call   1040 <fprintf@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    143e <main+0x2be>
jmp    13d0 <main+0x250>
jmp    13d5 <main+0x255>
jmp    13da <main+0x25a>
mov    $0x0,%al
call   1080 <test_tokenizer@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     1421 <main+0x2a1>
mov    0x2be3(%rip),%rax
mov    (%rax),%edi
lea    0xc02(%rip),%rsi
mov    $0x13d,%edx
lea    0xcaa(%rip),%rcx
call   1040 <fprintf@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x20(%rbp)
jmp    143e <main+0x2be>
jmp    1426 <main+0x2a6>
jmp    142b <main+0x2ab>
mov    0x2b9e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rbx
mov    %rsi,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    $0x1fd,%edx
call   1050 <get_tempdir@plt>
test   %eax,%eax
je     11de <main+0x5e>
mov    %eax,%r14d
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    0xe38(%rip),%rsi
lea    0xe48(%rip),%rcx
mov    $0x136,%edx
call   1040 <fprintf@plt>
jmp    131f <main+0x19f>
mov    %rbx,%rdi
call   1030 <register_tempdir_for_cleanup@plt>
test   %eax,%eax
je     1213 <main+0x93>
mov    %eax,%r14d
mov    0x2de4(%rip),%rax
mov    (%rax),%edi
lea    0xe03(%rip),%rsi
lea    0xe39(%rip),%rcx
mov    $0x137,%edx
call   1040 <fprintf@plt>
jmp    131f <main+0x19f>
mov    %rbx,%rdi
call   1070 <dump_empty_buf@plt>
test   %eax,%eax
je     1248 <main+0xc8>
mov    %eax,%r14d
mov    0x2daf(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
lea    0xe27(%rip),%rcx
mov    $0x139,%edx
call   1040 <fprintf@plt>
jmp    131f <main+0x19f>
mov    %rbx,%rdi
call   10a0 <dump_small_buf@plt>
test   %eax,%eax
je     127d <main+0xfd>
mov    %eax,%r14d
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
lea    0xe07(%rip),%rcx
mov    $0x13a,%edx
call   1040 <fprintf@plt>
jmp    131f <main+0x19f>
mov    %rbx,%rdi
call   1090 <fill_entire_buf@plt>
test   %eax,%eax
je     12af <main+0x12f>
mov    %eax,%r14d
mov    0x2d45(%rip),%rax
mov    (%rax),%edi
lea    0xd64(%rip),%rsi
lea    0xde7(%rip),%rcx
mov    $0x13b,%edx
call   1040 <fprintf@plt>
jmp    131f <main+0x19f>
mov    %rbx,%rdi
call   1060 <test_dump_all@plt>
test   %eax,%eax
je     12e1 <main+0x161>
mov    %eax,%r14d
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
lea    0xdcb(%rip),%rcx
mov    $0x13c,%edx
call   1040 <fprintf@plt>
jmp    131f <main+0x19f>
xor    %eax,%eax
call   1080 <test_tokenizer@plt>
mov    %eax,%r14d
test   %eax,%eax
je     1310 <main+0x190>
mov    0x2ce2(%rip),%rax
mov    (%rax),%edi
lea    0xd01(%rip),%rsi
lea    0xdae(%rip),%rcx
mov    $0x13d,%edx
call   1040 <fprintf@plt>
test   %r14d,%r14d
jne    131f <main+0x19f>
mov    0x2cb4(%rip),%rax
mov    (%rax),%r14d
mov    %r14d,%eax
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.1 = [38 x i8] c"get_tempdir(tdir, sizeof(tdir), 0775)\00"
@.str.2 = [35 x i8] c"register_tempdir_for_cleanup(tdir)\00"
@.str.3 = [21 x i8] c"dump_empty_buf(tdir)\00"
@.str.4 = [21 x i8] c"dump_small_buf(tdir)\00"
@.str.5 = [22 x i8] c"fill_entire_buf(tdir)\00"
@.str.6 = [20 x i8] c"test_dump_all(tdir)\00"
@.str.7 = [17 x i8] c"test_tokenizer()\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %1
%12 = load i32, i32* @PATH_MAX
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %2
%15 = alloca i8, i64 %13
store i64 %13, i64* %3
br label %16
16: ; preds = %0
%17 = trunc i64 %13 to i32
%18 = call i32 @get_tempdir(i8* %15, i32 %17, i32 509)
store i32 %18, i32* %4
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 310, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %4
store i32 %24, i32* %1
store i32 1, i32* %5
br label %95
25: ; preds = %16
br label %26
26: ; preds = %25
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
%29 = call i32 @register_tempdir_for_cleanup(i8* %15)
store i32 %29, i32* %6
%30 = load i32, i32* %6
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 311, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* %6
store i32 %35, i32* %1
store i32 1, i32* %5
br label %95
36: ; preds = %28
br label %37
37: ; preds = %36
br label %38
38: ; preds = %37
br label %39
39: ; preds = %38
%40 = call i32 @dump_empty_buf(i8* %15)
store i32 %40, i32* %7
%41 = load i32, i32* %7
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i32, i32* @stderr
%45 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 313, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%46 = load i32, i32* %7
store i32 %46, i32* %1
store i32 1, i32* %5
br label %95
47: ; preds = %39
br label %48
48: ; preds = %47
br label %49
49: ; preds = %48
br label %50
50: ; preds = %49
%51 = call i32 @dump_small_buf(i8* %15)
store i32 %51, i32* %8
%52 = load i32, i32* %8
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %50
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 314, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%57 = load i32, i32* %8
store i32 %57, i32* %1
store i32 1, i32* %5
br label %95
58: ; preds = %50
br label %59
59: ; preds = %58
br label %60
60: ; preds = %59
br label %61
61: ; preds = %60
%62 = call i32 @fill_entire_buf(i8* %15)
store i32 %62, i32* %9
%63 = load i32, i32* %9
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %61
%66 = load i32, i32* @stderr
%67 = call i32 @fprintf(i32 %66, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 315, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%68 = load i32, i32* %9
store i32 %68, i32* %1
store i32 1, i32* %5
br label %95
69: ; preds = %61
br label %70
70: ; preds = %69
br label %71
71: ; preds = %70
br label %72
72: ; preds = %71
%73 = call i32 @test_dump_all(i8* %15)
store i32 %73, i32* %10
%74 = load i32, i32* %10
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %80
76: ; preds = %72
%77 = load i32, i32* @stderr
%78 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 316, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%79 = load i32, i32* %10
store i32 %79, i32* %1
store i32 1, i32* %5
br label %95
80: ; preds = %72
br label %81
81: ; preds = %80
br label %82
82: ; preds = %81
br label %83
83: ; preds = %82
%84 = call i32 (...) @test_tokenizer()
store i32 %84, i32* %11
%85 = load i32, i32* %11
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %91
87: ; preds = %83
%88 = load i32, i32* @stderr
%89 = call i32 @fprintf(i32 %88, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 317, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%90 = load i32, i32* %11
store i32 %90, i32* %1
store i32 1, i32* %5
br label %95
91: ; preds = %83
br label %92
92: ; preds = %91
br label %93
93: ; preds = %92
%94 = load i32, i32* @EXIT_SUCCESS
store i32 %94, i32* %1
store i32 1, i32* %5
br label %95
95: ; preds = %93, %87, %76, %65, %54, %43, %32, %21
%96 = load i8*, i8** %2
%97 = load i32, i32* %1
ret i32 %97
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@stderr = global i32 0
@.str = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.1 = [38 x i8] c"get_tempdir(tdir, sizeof(tdir), 0775)\00"
@.str.2 = [35 x i8] c"register_tempdir_for_cleanup(tdir)\00"
@.str.3 = [21 x i8] c"dump_empty_buf(tdir)\00"
@.str.4 = [21 x i8] c"dump_small_buf(tdir)\00"
@.str.5 = [22 x i8] c"fill_entire_buf(tdir)\00"
@.str.6 = [20 x i8] c"test_dump_all(tdir)\00"
@.str.7 = [17 x i8] c"test_tokenizer()\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = load i32, i32* @PATH_MAX
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = call i32 @get_tempdir(i8* %3, i32 %1, i32 509)
%5 = icmp eq i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = load i32, i32* @stderr
%8 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 310, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
br label %48
9: ; preds = %0
%10 = call i32 @register_tempdir_for_cleanup(i8* %3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 311, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0))
br label %48
15: ; preds = %9
%16 = call i32 @dump_empty_buf(i8* %3)
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 313, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %48
21: ; preds = %15
%22 = call i32 @dump_small_buf(i8* %3)
%23 = icmp eq i32 %22, 0
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 314, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
br label %48
27: ; preds = %21
%28 = call i32 @fill_entire_buf(i8* %3)
%29 = icmp eq i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 315, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
br label %48
33: ; preds = %27
%34 = call i32 @test_dump_all(i8* %3)
%35 = icmp eq i32 %34, 0
br i1 %35, label %39, label %36
36: ; preds = %33
%37 = load i32, i32* @stderr
%38 = call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 316, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %48
39: ; preds = %33
%40 = call i32 (...) @test_tokenizer()
%41 = icmp eq i32 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 317, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
br label %45
45: ; preds = %39, %42
%46 = load i32, i32* @EXIT_SUCCESS
%47 = select i1 %41, i32 %46, i32 %40
br label %48
48: ; preds = %36, %30, %24, %18, %12, %6, %45
%49 = phi i32 [ %34, %36 ], [ %28, %30 ], [ %22, %24 ], [ %16, %18 ], [ %10, %12 ], [ %4, %6 ], [ %47, %45 ]
ret i32 %49
}