#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 */
char EOF;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, char);
void instrukcja() {
  FILE *zw;
  char zp;
  zw = fopen("instrukcja.txt", "r");
  while (zp != EOF) {
    zp = fgetc(zw);
    printf("%c", zp);
  }
  fclose(zw);
}


x86 assembly (clang, -O0):
<instrukcja>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
lea    0xeb9(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x8(%rbp)
movsbl -0x9(%rbp),%eax
mov    0x2e7e(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1196 <instrukcja+0x56>
mov    -0x8(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x9(%rbp)
lea    0xe89(%rip),%rdi
movsbl -0x9(%rbp),%esi
call   1040 <printf@plt>
jmp    115f <instrukcja+0x1f>
mov    -0x8(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<instrukcja>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb2(%rip),%rdi
lea    0xeba(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
lea    0xead(%rip),%r14
mov    0x2e7d(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
movsbl %al,%ebp
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
cmp    (%r15),%bpl
jne    1170 <instrukcja+0x30>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"instrukcja.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [3 x i8] c"%c\00"
define void @instrukcja() {
%1 = alloca i32*
%2 = alloca i8
%3 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %3, i32** %1
br label %4
4: ; preds = %10, %0
%5 = load i8, i8* %2
%6 = sext i8 %5 to i32
%7 = load i8, i8* @EOF
%8 = sext i8 %7 to i32
%9 = icmp ne i32 %6, %8
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = load i32*, i32** %1
%12 = call signext i8 @fgetc(i32* %11)
store i8 %12, i8* %2
%13 = load i8, i8* %2
%14 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %13)
br label %4
15: ; preds = %4
%16 = load i32*, i32** %1
%17 = call i32 @fclose(i32* %16)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"instrukcja.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [3 x i8] c"%c\00"
define void @instrukcja() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 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 = tail call signext i8 @fgetc(i32* %1)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %3)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %3, %5
br i1 %6, label %7, label %2
7: ; preds = %2
%8 = tail call i32 @fclose(i32* %1)
ret void
}