#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*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ refine(int /*<<< orphan*/, int /*<<< orphan*/ *, int const);
int /*<<< orphan*/ stdout;
int main(void) {
  const int limit = 80;
  FILE *fp = fopen("res/input04.txt", "r");
  int i;
  for (i = 0; i < limit; ++i)
    printf(" ");
  printf("| %d\n", limit);
  refine(stdout, fp, limit);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x50,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x50,-0x14(%rbp)
jge    118a <main+0x5a>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <main+0x34>
lea    0xe83(%rip),%rdi
mov    $0x50,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    $0x50,%edx
call   1040 <refine@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xeb6(%rip),%rdi
lea    0xebf(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
mov    $0x50,%ebp
xchg   %ax,%ax
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1160 <main+0x20>
lea    0xe9c(%rip),%rdi
mov    $0x50,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
mov    $0x50,%edx
call   1050 <refine@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"res/input04.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [6 x i8] c"| %d\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
store i32 0, i32* %1
store i32 80, i32* %2
%5 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %5, i32** %3
store i32 0, i32* %4
br label %6
6: ; preds = %11, %0
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 80
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 1
store i32 %13, i32* %4
br label %6
14: ; preds = %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 80)
%16 = load i32, i32* @stdout
%17 = load i32*, i32** %3
%18 = call i32 @refine(i32 %16, i32* %17, i32 80)
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [16 x i8] c"res/input04.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.3 = [6 x i8] c"| %d\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %5, %2 ]
%4 = tail call i32 @putchar(i32 32)
%5 = add nuw nsw i32 %3, 1
%6 = icmp eq i32 %5, 80
br i1 %6, label %7, label %2
7: ; preds = %2
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 80)
%9 = load i32, i32* @stdout
%10 = tail call i32 @refine(i32 %9, i32* %1, i32 80)
ret i32 0
}