#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*/ function(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  FILE *input;
  printf("23 in hexa %#perrorX.\n", 23);
  printf("Enter 4 numbers to be scanned:\n");
  input = fopen("4nre.txt", "r");
  if (input == NULL) {
    perror("heroare");
  }
  function(input);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x17,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
lea    0xec2(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    119e <main+0x5e>
lea    0xea9(%rip),%rdi
call   1060 <perror@plt>
mov    -0x10(%rbp),%rdi
call   1040 <function@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
mov    $0x17,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1197 <main+0x47>
mov    %rbx,%rdi
call   1050 <function@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe84(%rip),%rdi
call   1070 <perror@plt>
jmp    118b <main+0x3b>

LLVM IR (-O0):
@.str = [23 x i8] c"23 in hexa %#perrorX.\0A\00"
@.str.1 = [32 x i8] c"Enter 4 numbers to be scanned:\0A\00"
@.str.2 = [9 x i8] c"4nre.txt\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [8 x i8] c"heroare\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 23)
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %5, i32** %2
%6 = load i32*, i32** %2
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %10
10: ; preds = %8, %0
%11 = load i32*, i32** %2
%12 = call i32 @function(i32* %11)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"23 in hexa %#perrorX.\0A\00"
@.str.2 = [9 x i8] c"4nre.txt\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [8 x i8] c"heroare\00"
@str = [31 x i8] c"Enter 4 numbers to be scanned:\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 23)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%3 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %7
7: ; preds = %5, %0
%8 = tail call i32 @function(i32* %3)
ret i32 0
}