#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*/ api_cmdline(char *, int);
int /*<<< orphan*/ api_end();
int api_fopen(char *);
scalar_t__ api_fread(char *, int, int);
int /*<<< orphan*/ api_putchar(char);
int /*<<< orphan*/ api_putstr0(char *);
void HariMain(void) {
  int fh;
  char c, cmdline[30], *p;
  api_cmdline(cmdline, 30);
  for (p = cmdline; *p > ' '; p++) {
  }
  for (; *p == ' '; p++) {
  }
  fh = api_fopen(p);
  if (fh != 0) {
    for (;;) {
      if (api_fread(&c, 1, fh) == 0) {
        break;
      }
      api_putchar(c);
    }
  } else {
    api_putstr0("File not found.\n");
  }
  api_end();
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
mov    $0x1e,%esi
call   1070 <api_cmdline@plt>
lea    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jle    11a4 <HariMain+0x44>
jmp    1193 <HariMain+0x33>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    117e <HariMain+0x1e>
jmp    11a9 <HariMain+0x49>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jne    11cf <HariMain+0x6f>
jmp    11be <HariMain+0x5e>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11a9 <HariMain+0x49>
mov    -0x38(%rbp),%rdi
call   1040 <api_fopen@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     121d <HariMain+0xbd>
jmp    11ea <HariMain+0x8a>
mov    -0x4(%rbp),%edx
lea    -0x5(%rbp),%rdi
mov    $0x1,%esi
call   1050 <api_fread@plt>
cmp    $0x0,%rax
jne    120a <HariMain+0xaa>
jmp    1218 <HariMain+0xb8>
movsbl -0x5(%rbp),%edi
call   1060 <api_putchar@plt>
jmp    11ea <HariMain+0x8a>
jmp    1229 <HariMain+0xc9>
lea    0xddc(%rip),%rdi
call   1080 <api_putstr0@plt>
mov    $0x0,%al
call   1030 <api_end@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HariMain>:
push   %r14
push   %rbx
sub    $0x38,%rsp
lea    0x10(%rsp),%rdi
mov    $0x1e,%esi
call   1070 <api_cmdline@plt>
lea    0xf(%rsp),%rax
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,0x1(%rax)
lea    0x1(%rax),%rax
jg     1180 <HariMain+0x20>
jne    119f <HariMain+0x3f>
nopl   0x0(%rax)
lea    0x1(%rax),%rdi
cmpb   $0x20,0x1(%rax)
mov    %rdi,%rax
je     1190 <HariMain+0x30>
jmp    11a2 <HariMain+0x42>
mov    %rax,%rdi
call   1040 <api_fopen@plt>
test   %eax,%eax
je     11f0 <HariMain+0x90>
mov    %eax,%ebx
lea    0xf(%rsp),%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1050 <api_fread@plt>
test   %rax,%rax
je     11fc <HariMain+0x9c>
lea    0xf(%rsp),%r14
nopl   0x0(%rax,%rax,1)
movsbl 0xf(%rsp),%edi
call   1060 <api_putchar@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1050 <api_fread@plt>
test   %rax,%rax
jne    11d0 <HariMain+0x70>
jmp    11fc <HariMain+0x9c>
lea    0xe09(%rip),%rdi
call   1080 <api_putstr0@plt>
xor    %eax,%eax
call   1030 <api_end@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"File not found.\0A\00"
define void @HariMain() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [30 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
%6 = call i32 @api_cmdline(i8* %5, i32 30)
%7 = getelementptr inbounds [30 x i8], [30 x i8]* %3, i64 0, i64 0
store i8* %7, i8** %4
br label %8
8: ; preds = %14, %0
%9 = load i8*, i8** %4
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp sgt i32 %11, 32
br i1 %12, label %13, label %17
13: ; preds = %8
br label %14
14: ; preds = %13
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %4
br label %8
17: ; preds = %8
br label %18
18: ; preds = %24, %17
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 32
br i1 %22, label %23, label %27
23: ; preds = %18
br label %24
24: ; preds = %23
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
br label %18
27: ; preds = %18
%28 = load i8*, i8** %4
%29 = call i32 @api_fopen(i8* %28)
store i32 %29, i32* %1
%30 = load i32, i32* %1
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %42
32: ; preds = %27
br label %33
33: ; preds = %38, %32
%34 = load i32, i32* %1
%35 = call i64 @api_fread(i8* %2, i32 1, i32 %34)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
br label %41
38: ; preds = %33
%39 = load i8, i8* %2
%40 = call i32 @api_putchar(i8 signext %39)
br label %33
41: ; preds = %37
br label %44
42: ; preds = %27
%43 = call i32 @api_putstr0(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %44
44: ; preds = %42, %41
%45 = call i32 (...) @api_end()
ret void
}

LLVM IR (-O2):
@.str = [17 x i8] c"File not found.\0A\00"
define void @HariMain() {
%1 = alloca i8
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%4 = call i32 @api_cmdline(i8* %3, i32 30)
br label %5
5: ; preds = %5, %0
%6 = phi i8* [ %3, %0 ], [ %9, %5 ]
%7 = load i8, i8* %6
%8 = icmp sgt i8 %7, 32
%9 = getelementptr inbounds i8, i8* %6, i64 1
br i1 %8, label %5, label %10
10: ; preds = %5
%11 = icmp eq i8 %7, 32
br i1 %11, label %12, label %17
12: ; preds = %10, %12
%13 = phi i8* [ %14, %12 ], [ %6, %10 ]
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 32
br i1 %16, label %12, label %17
17: ; preds = %12, %10
%18 = phi i8* [ %6, %10 ], [ %14, %12 ]
%19 = call i32 @api_fopen(i8* %18)
%20 = icmp eq i32 %19, 0
br i1 %20, label %29, label %21
21: ; preds = %17
%22 = call i64 @api_fread(i8* %1, i32 1, i32 %19)
%23 = icmp eq i64 %22, 0
br i1 %23, label %31, label %24
24: ; preds = %21, %24
%25 = load i8, i8* %1
%26 = call i32 @api_putchar(i8 signext %25)
%27 = call i64 @api_fread(i8* %1, i32 1, i32 %19)
%28 = icmp eq i64 %27, 0
br i1 %28, label %31, label %24
29: ; preds = %17
%30 = call i32 @api_putstr0(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %24, %21, %29
%32 = call i32 (...) @api_end()
ret void
}