#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*/ fscanf(int /*<<< orphan*/ *, char *, int *);
void read_instructions(int *instructions, FILE *fd, int num_inst) {
  for (volatile unsigned int i = 0x00; i < num_inst;
       fscanf(fd, "%i", instructions + (i++)))
    ;
}


x86 assembly (clang, -O0):
<read_instructions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1168 <read_instructions+0x58>
jmp    113b <read_instructions+0x2b>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x18(%rbp)
mov    %eax,%eax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xea2(%rip),%rsi
call   1030 <fscanf@plt>
jmp    112a <read_instructions+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_instructions>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
mov    0x4(%rsp),%eax
cmp    %edx,%eax
jae    1162 <read_instructions+0x52>
mov    %edx,%ebx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xec9(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    0x4(%rsp),%eax
lea    0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
lea    (%r15,%rax,4),%rdx
mov    %r14,%rdi
mov    %r12,%rsi
call   1030 <fscanf@plt>
mov    0x4(%rsp),%eax
cmp    %ebx,%eax
jb     1140 <read_instructions+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
define void @read_instructions(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store volatile i32 0, i32* %7
br label %8
8: ; preds = %13, %3
%9 = load volatile i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp ult i32 %9, %10
br i1 %11, label %12, label %21
12: ; preds = %8
br label %13
13: ; preds = %12
%14 = load i32*, i32** %5
%15 = load i32*, i32** %4
%16 = load volatile i32, i32* %7
%17 = add i32 %16, 1
store volatile i32 %17, i32* %7
%18 = zext i32 %16 to i64
%19 = getelementptr inbounds i32, i32* %15, i64 %18
%20 = call i32 @fscanf(i32* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
br label %8
21: ; preds = %8
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
define void @read_instructions(i32* %0, i32* nocapture %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store volatile i32 0, i32* %4
%6 = load volatile i32, i32* %4
%7 = icmp ult i32 %6, %2
br i1 %7, label %9, label %8
8: ; preds = %9, %3
ret void
9: ; preds = %3, %9
%10 = load volatile i32, i32* %4
%11 = add i32 %10, 1
store volatile i32 %11, i32* %4
%12 = zext i32 %10 to i64
%13 = getelementptr inbounds i32, i32* %0, i64 %12
%14 = tail call i32 @fscanf(i32* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%15 = load volatile i32, i32* %4
%16 = icmp ult i32 %15, %2
br i1 %16, label %9, label %8
}