#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  FILE *fd;
  char b;
  char file_buf[20];
  int i, len;
  if ((fd = fopen(argv[1], "rb")) == NULL) {
    printf("open file err\n");
    return 1;
  }
  while ((len = fread(file_buf, 1, 16, fd) > 0)) {
    for (i = 0; i < len; i++)
      printf("%c", file_buf[i]);
  }
  fclose(fd);
  printf("\n");
  write(1, "fuck\n", 6);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe8b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11a2 <main+0x52>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124e <main+0xfe>
jmp    11a7 <main+0x57>
lea    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x10,%edx
call   1030 <fread@plt>
cmp    $0x0,%rax
setg   %al
mov    %al,%cl
and    $0x1,%cl
movzbl %cl,%ecx
mov    %ecx,-0x38(%rbp)
test   $0x1,%al
jne    11dd <main+0x8d>
jmp    121a <main+0xca>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1215 <main+0xc5>
movslq -0x34(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11e4 <main+0x94>
jmp    11a7 <main+0x57>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
lea    0xdd8(%rip),%rsi
mov    $0x6,%edx
call   1040 <write@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%rdi
lea    0xe8e(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     11ef <main+0x8f>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %rax,%rcx
call   1050 <fread@plt>
test   %rax,%rax
jle    11c3 <main+0x63>
mov    %rsp,%r14
nopl   0x0(%rax)
movsbl (%rsp),%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x10,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
test   %rax,%rax
jg     11a0 <main+0x40>
mov    %rbx,%rdi
call   1070 <fclose@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe27(%rip),%rsi
mov    $0x1,%edi
mov    $0x6,%edx
call   1060 <write@plt>
xor    %eax,%eax
jmp    1200 <main+0xa0>
lea    0xe13(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [15 x i8] c"open file err\0A\00"
@.str.2 = [3 x i8] c"%c\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [6 x i8] c"fuck\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8
%8 = alloca [20 x i8]
%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 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %46
18: ; preds = %2
br label %19
19: ; preds = %40, %18
%20 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 0
%21 = load i32*, i32** %6
%22 = call i64 @fread(i8* %20, i32 1, i32 16, i32* %21)
%23 = icmp sgt i64 %22, 0
%24 = zext i1 %23 to i32
store i32 %24, i32* %10
br i1 %23, label %25, label %41
25: ; preds = %19
store i32 0, i32* %9
br label %26
26: ; preds = %37, %25
%27 = load i32, i32* %9
%28 = load i32, i32* %10
%29 = icmp slt i32 %27, %28
br i1 %29, label %30, label %40
30: ; preds = %26
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [20 x i8], [20 x i8]* %8, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %30
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %26
40: ; preds = %26
br label %19
41: ; preds = %19
%42 = load i32*, i32** %6
%43 = call i32 @fclose(i32* %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%45 = call i32 @write(i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 6)
store i32 0, i32* %3
br label %46
46: ; preds = %41, %16
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.4 = [6 x i8] c"fuck\0A\00"
@str = [14 x i8] c"open file err\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [20 x i8]
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = call i64 @fread(i8* %4, i32 1, i32 16, i32* %7)
%11 = icmp sgt i64 %10, 0
br i1 %11, label %14, label %20
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %24
14: ; preds = %9, %14
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = tail call i32 @putchar(i32 %16)
%18 = call i64 @fread(i8* %4, i32 1, i32 16, i32* %7)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %14, label %20
20: ; preds = %14, %9
%21 = tail call i32 @fclose(i32* %7)
%22 = tail call i32 @putchar(i32 10)
%23 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32 6)
br label %24
24: ; preds = %20, %12
%25 = phi i32 [ 1, %12 ], [ 0, %20 ]
ret i32 %25
}