#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_end();
int api_fopen(char *);
scalar_t__ api_fread(char *, int, int);
int /*<<< orphan*/ api_putchar(char);
void HariMain(void) {
  int fh;
  char c;
  fh = api_fopen("ipl10.nas");
  if (fh != 0) {
    for (;;) {
      if (api_fread(&c, 1, fh) == 0) {
        break;
      }
      api_putchar(c);
    }
  }
  api_end();
}


x86 assembly (clang, -O0):
<HariMain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
call   1040 <api_fopen@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     1199 <HariMain+0x59>
jmp    1166 <HariMain+0x26>
mov    -0x4(%rbp),%edx
lea    -0x5(%rbp),%rdi
mov    $0x1,%esi
call   1050 <api_fread@plt>
cmp    $0x0,%rax
jne    1186 <HariMain+0x46>
jmp    1194 <HariMain+0x54>
movsbl -0x5(%rbp),%edi
call   1060 <api_putchar@plt>
jmp    1166 <HariMain+0x26>
jmp    1199 <HariMain+0x59>
mov    $0x0,%al
call   1030 <api_end@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HariMain>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
call   1040 <api_fopen@plt>
test   %eax,%eax
je     119e <HariMain+0x5e>
mov    %eax,%ebx
lea    0x7(%rsp),%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1050 <api_fread@plt>
test   %rax,%rax
je     119e <HariMain+0x5e>
lea    0x7(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl 0x7(%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    1180 <HariMain+0x40>
xor    %eax,%eax
call   1030 <api_end@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"ipl10.nas\00"
define void @HariMain() {
%1 = alloca i32
%2 = alloca i8
%3 = call i32 @api_fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 %3, i32* %1
%4 = load i32, i32* %1
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %16
6: ; preds = %0
br label %7
7: ; preds = %12, %6
%8 = load i32, i32* %1
%9 = call i64 @api_fread(i8* %2, i32 1, i32 %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %15
12: ; preds = %7
%13 = load i8, i8* %2
%14 = call i32 @api_putchar(i8 signext %13)
br label %7
15: ; preds = %11
br label %16
16: ; preds = %15, %0
%17 = call i32 (...) @api_end()
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"ipl10.nas\00"
define void @HariMain() {
%1 = alloca i8
%2 = tail call i32 @api_fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %12, label %4
4: ; preds = %0
%5 = call i64 @api_fread(i8* %1, i32 1, i32 %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4, %7
%8 = load i8, i8* %1
%9 = call i32 @api_putchar(i8 signext %8)
%10 = call i64 @api_fread(i8* %1, i32 1, i32 %2)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %7
12: ; preds = %7, %4, %0
%13 = call i32 (...) @api_end()
ret void
}