#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 /*<<< orphan*/ fail(char *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int outbyte(char);
int /*<<< orphan*/ pass(char *);
int print(char *);
int /*<<< orphan*/ putnum(int);
int read(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ stdout;
int write(char *, int);
main() {
  char buf[100];
  char *tmp;
  int result;
  result = outbyte('&');
  if (result != 0x0) {
    pass("outbyte");
  } else {
    fail("outbyte");
  }
  result = write("Write Test:\n", 12);
  print("result was ");
  putnum(result);
  outbyte('\n');
  if (result == 12) {
    pass("write");
  } else {
    fail("write");
  }
  result = print("Print Test:\n");
  print("result was ");
  putnum(result);
  outbyte('\n');
  if (result == 12) {
    pass("print");
  } else {
    fail("print");
  }
  result = print("Iprintf Test:\n");
  print("result was ");
  putnum(result);
  outbyte('\n');
  if (result == 14) {
    pass("iprintf");
  } else {
    fail("iprintf");
  }
  print("Type 5 characters");
  result = 0;
  result = read(0, buf, 5);
  print(buf);
  if (result == 5) {
    pass("read");
  } else {
    fail("read");
  }
  fflush(stdout);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x26,%edi
call   10a0 <outbyte@plt>
mov    %eax,-0x7c(%rbp)
cmpl   $0x0,-0x7c(%rbp)
je     11ba <main+0x3a>
lea    0xe50(%rip),%rdi
call   1050 <pass@plt>
jmp    11c6 <main+0x46>
lea    0xe3f(%rip),%rdi
call   1040 <fail@plt>
lea    0xe3b(%rip),%rdi
mov    $0xc,%esi
call   1030 <write@plt>
mov    %eax,-0x7c(%rbp)
lea    0xe34(%rip),%rdi
call   1060 <print@plt>
mov    -0x7c(%rbp),%edi
call   1090 <putnum@plt>
mov    $0xa,%edi
call   10a0 <outbyte@plt>
cmpl   $0xc,-0x7c(%rbp)
jne    1213 <main+0x93>
lea    0xe18(%rip),%rdi
call   1050 <pass@plt>
jmp    121f <main+0x9f>
lea    0xe07(%rip),%rdi
call   1040 <fail@plt>
lea    0xe01(%rip),%rdi
call   1060 <print@plt>
mov    %eax,-0x7c(%rbp)
lea    0xde0(%rip),%rdi
call   1060 <print@plt>
mov    -0x7c(%rbp),%edi
call   1090 <putnum@plt>
mov    $0xa,%edi
call   10a0 <outbyte@plt>
cmpl   $0xc,-0x7c(%rbp)
jne    1267 <main+0xe7>
lea    0xdd7(%rip),%rdi
call   1050 <pass@plt>
jmp    1273 <main+0xf3>
lea    0xdc6(%rip),%rdi
call   1040 <fail@plt>
lea    0xdc0(%rip),%rdi
call   1060 <print@plt>
mov    %eax,-0x7c(%rbp)
lea    0xd8c(%rip),%rdi
call   1060 <print@plt>
mov    -0x7c(%rbp),%edi
call   1090 <putnum@plt>
mov    $0xa,%edi
call   10a0 <outbyte@plt>
cmpl   $0xe,-0x7c(%rbp)
jne    12bb <main+0x13b>
lea    0xd98(%rip),%rdi
call   1050 <pass@plt>
jmp    12c7 <main+0x147>
lea    0xd87(%rip),%rdi
call   1040 <fail@plt>
lea    0xd83(%rip),%rdi
call   1060 <print@plt>
movl   $0x0,-0x7c(%rbp)
lea    -0x70(%rbp),%rsi
xor    %edi,%edi
mov    $0x5,%edx
call   1070 <read@plt>
mov    %eax,-0x7c(%rbp)
lea    -0x70(%rbp),%rdi
call   1060 <print@plt>
cmpl   $0x5,-0x7c(%rbp)
jne    1311 <main+0x191>
lea    0xd5c(%rip),%rdi
call   1050 <pass@plt>
jmp    131d <main+0x19d>
lea    0xd4b(%rip),%rdi
call   1040 <fail@plt>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x68,%rsp
mov    $0x26,%edi
call   10a0 <outbyte@plt>
lea    0xe69(%rip),%rdi
test   %eax,%eax
je     11a2 <main+0x22>
call   1050 <pass@plt>
jmp    11a7 <main+0x27>
call   1040 <fail@plt>
lea    0xe5a(%rip),%rdi
mov    $0xc,%esi
call   1030 <write@plt>
mov    %eax,%ebx
lea    0xe54(%rip),%rdi
call   1060 <print@plt>
mov    %ebx,%edi
call   1090 <putnum@plt>
mov    $0xa,%edi
call   10a0 <outbyte@plt>
lea    0xe43(%rip),%rdi
cmp    $0xc,%ebx
jne    11ea <main+0x6a>
call   1050 <pass@plt>
jmp    11ef <main+0x6f>
call   1040 <fail@plt>
lea    0xe31(%rip),%rdi
call   1060 <print@plt>
mov    %eax,%ebx
lea    0xe11(%rip),%rdi
call   1060 <print@plt>
mov    %ebx,%edi
call   1090 <putnum@plt>
mov    $0xa,%edi
call   10a0 <outbyte@plt>
lea    0xe13(%rip),%rdi
cmp    $0xc,%ebx
jne    122d <main+0xad>
call   1050 <pass@plt>
jmp    1232 <main+0xb2>
call   1040 <fail@plt>
lea    0xe01(%rip),%rdi
call   1060 <print@plt>
mov    %eax,%ebx
lea    0xdce(%rip),%rdi
call   1060 <print@plt>
mov    %ebx,%edi
call   1090 <putnum@plt>
mov    $0xa,%edi
call   10a0 <outbyte@plt>
lea    0xde5(%rip),%rdi
cmp    $0xe,%ebx
jne    1270 <main+0xf0>
call   1050 <pass@plt>
jmp    1275 <main+0xf5>
call   1040 <fail@plt>
lea    0xdd5(%rip),%rdi
call   1060 <print@plt>
mov    %rsp,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1070 <read@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <print@plt>
lea    0xdbf(%rip),%rdi
cmp    $0x5,%ebp
jne    12b0 <main+0x130>
call   1050 <pass@plt>
jmp    12b5 <main+0x135>
call   1040 <fail@plt>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
call   1080 <fflush@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"outbyte\00"
@.str.1 = [13 x i8] c"Write Test:\0A\00"
@.str.2 = [12 x i8] c"result was \00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [13 x i8] c"Print Test:\0A\00"
@.str.5 = [6 x i8] c"print\00"
@.str.6 = [15 x i8] c"Iprintf Test:\0A\00"
@.str.7 = [8 x i8] c"iprintf\00"
@.str.8 = [18 x i8] c"Type 5 characters\00"
@.str.9 = [5 x i8] c"read\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8*
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @outbyte(i8 signext 38)
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @pass(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %0
%11 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
%13 = call i32 @write(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 12)
store i32 %13, i32* %4
%14 = call i32 @print(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* %4
%16 = call i32 @putnum(i32 %15)
%17 = call i32 @outbyte(i8 signext 10)
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 12
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 @pass(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %24
22: ; preds = %12
%23 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %24
24: ; preds = %22, %20
%25 = call i32 @print(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
store i32 %25, i32* %4
%26 = call i32 @print(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%27 = load i32, i32* %4
%28 = call i32 @putnum(i32 %27)
%29 = call i32 @outbyte(i8 signext 10)
%30 = load i32, i32* %4
%31 = icmp eq i32 %30, 12
br i1 %31, label %32, label %34
32: ; preds = %24
%33 = call i32 @pass(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %36
34: ; preds = %24
%35 = call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
%37 = call i32 @print(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
store i32 %37, i32* %4
%38 = call i32 @print(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* %4
%40 = call i32 @putnum(i32 %39)
%41 = call i32 @outbyte(i8 signext 10)
%42 = load i32, i32* %4
%43 = icmp eq i32 %42, 14
br i1 %43, label %44, label %46
44: ; preds = %36
%45 = call i32 @pass(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %48
46: ; preds = %36
%47 = call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
%49 = call i32 @print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %4
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%51 = call i32 @read(i32 0, i8* %50, i32 5)
store i32 %51, i32* %4
%52 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%53 = call i32 @print(i8* %52)
%54 = load i32, i32* %4
%55 = icmp eq i32 %54, 5
br i1 %55, label %56, label %58
56: ; preds = %48
%57 = call i32 @pass(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %60
58: ; preds = %48
%59 = call i32 @fail(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %60
60: ; preds = %58, %56
%61 = load i32, i32* @stdout
%62 = call i32 @fflush(i32 %61)
%63 = load i32, i32* %1
ret i32 %63
}

LLVM IR (-O2):
@.str = [8 x i8] c"outbyte\00"
@.str.1 = [13 x i8] c"Write Test:\0A\00"
@.str.2 = [12 x i8] c"result was \00"
@.str.3 = [6 x i8] c"write\00"
@.str.4 = [13 x i8] c"Print Test:\0A\00"
@.str.5 = [6 x i8] c"print\00"
@.str.6 = [15 x i8] c"Iprintf Test:\0A\00"
@.str.7 = [8 x i8] c"iprintf\00"
@.str.8 = [18 x i8] c"Type 5 characters\00"
@.str.9 = [5 x i8] c"read\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @outbyte(i8 signext 38)
%4 = icmp eq i32 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %0
%6 = tail call i32 @pass(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %9
7: ; preds = %0
%8 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %5
%10 = tail call i32 @write(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 12)
%11 = tail call i32 @print(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @putnum(i32 %10)
%13 = tail call i32 @outbyte(i8 signext 10)
%14 = icmp eq i32 %10, 12
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = tail call i32 @pass(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %19
17: ; preds = %9
%18 = tail call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %19
19: ; preds = %17, %15
%20 = tail call i32 @print(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%21 = tail call i32 @print(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%22 = tail call i32 @putnum(i32 %20)
%23 = tail call i32 @outbyte(i8 signext 10)
%24 = icmp eq i32 %20, 12
br i1 %24, label %25, label %27
25: ; preds = %19
%26 = tail call i32 @pass(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %29
27: ; preds = %19
%28 = tail call i32 @fail(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = tail call i32 @print(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%31 = tail call i32 @print(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%32 = tail call i32 @putnum(i32 %30)
%33 = tail call i32 @outbyte(i8 signext 10)
%34 = icmp eq i32 %30, 14
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = tail call i32 @pass(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %39
37: ; preds = %29
%38 = tail call i32 @fail(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %39
39: ; preds = %37, %35
%40 = tail call i32 @print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%41 = call i32 @read(i32 0, i8* %2, i32 5)
%42 = call i32 @print(i8* %2)
%43 = icmp eq i32 %41, 5
br i1 %43, label %44, label %46
44: ; preds = %39
%45 = call i32 @pass(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %48
46: ; preds = %39
%47 = call i32 @fail(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
br label %48
48: ; preds = %46, %44
%49 = load i32, i32* @stdout
%50 = call i32 @fflush(i32 %49)
ret i32 0
}