#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 atoi(char *);
char fgetc(int /*<<< orphan*/ *);
void get_item_prices(int prices[2001], FILE *in_file) {
  char c;
  int count;
  int price_count;
  char line[6];
  count = 0;
  price_count = 0;
  while (1) {
    c = fgetc(in_file);
    if (c == '\0' || c == '\n') {
      line[count] = '\0';
      prices[price_count] = atoi(line);
      break;
    }
    if (c == ' ') {
      line[count] = '\0';
      prices[price_count] = atoi(line);
      price_count++;
      count = 0;
    }
    line[count] = c;
    count++;
  }
  return;
}


x86 assembly (clang, -O0):
<get_item_prices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     1164 <get_item_prices+0x44>
movsbl -0x11(%rbp),%eax
cmp    $0xa,%eax
jne    1188 <get_item_prices+0x68>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x22(%rbp,%rax,1)
lea    -0x22(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11dd <get_item_prices+0xbd>
movsbl -0x11(%rbp),%eax
cmp    $0x20,%eax
jne    11c4 <get_item_prices+0xa4>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x22(%rbp,%rax,1)
lea    -0x22(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x11(%rbp),%cl
movslq -0x18(%rbp),%rax
mov    %cl,-0x22(%rbp,%rax,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113e <get_item_prices+0x1e>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_item_prices>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
xor    %ebp,%ebp
lea    0x2(%rsp),%r15
xor    %r13d,%r13d
jmp    1167 <get_item_prices+0x47>
nopl   (%rax)
movslq %ebp,%rax
movb   $0x0,0x2(%rsp,%rax,1)
mov    %r15,%rdi
call   1040 <atoi@plt>
movslq %r13d,%r13
mov    %eax,(%r14,%r13,4)
add    $0x1,%r13d
xor    %ebp,%ebp
movslq %ebp,%rbp
mov    %bl,0x2(%rsp,%rbp,1)
add    $0x1,%ebp
mov    %r12,%rdi
call   1030 <fgetc@plt>
mov    %eax,%ebx
cmp    $0x20,%al
je     1140 <get_item_prices+0x20>
cmp    $0xa,%bl
je     117e <get_item_prices+0x5e>
test   %bl,%bl
jne    115d <get_item_prices+0x3d>
movslq %ebp,%rax
movb   $0x0,0x2(%rsp,%rax,1)
lea    0x2(%rsp),%rdi
call   1040 <atoi@plt>
movslq %r13d,%rcx
mov    %eax,(%r14,%rcx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @get_item_prices(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca [6 x i8]
store i32* %0, i32** %3
store i32* %1, i32** %4
store i32 0, i32* %6
store i32 0, i32* %7
br label %9
9: ; preds = %2, %45
%10 = load i32*, i32** %4
%11 = call signext i8 @fgetc(i32* %10)
store i8 %11, i8* %5
%12 = load i8, i8* %5
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %9
%16 = load i8, i8* %5
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 10
br i1 %18, label %19, label %29
19: ; preds = %15, %9
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 %21
store i8 0, i8* %22
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%24 = call i32 @atoi(i8* %23)
%25 = load i32*, i32** %3
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
store i32 %24, i32* %28
br label %52
29: ; preds = %15
%30 = load i8, i8* %5
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 32
br i1 %32, label %33, label %45
33: ; preds = %29
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 %35
store i8 0, i8* %36
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%38 = call i32 @atoi(i8* %37)
%39 = load i32*, i32** %3
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %39, i64 %41
store i32 %38, i32* %42
%43 = load i32, i32* %7
%44 = add nsw i32 %43, 1
store i32 %44, i32* %7
store i32 0, i32* %6
br label %45
45: ; preds = %33, %29
%46 = load i8, i8* %5
%47 = load i32, i32* %6
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 %48
store i8 %46, i8* %49
%50 = load i32, i32* %6
%51 = add nsw i32 %50, 1
store i32 %51, i32* %6
br label %9
52: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @get_item_prices(i32* nocapture writeonly %0, i32* nocapture %1) {
%3 = alloca [6 x i8]
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
br label %5
5: ; preds = %22, %2
%6 = phi i32 [ 0, %2 ], [ %27, %22 ]
%7 = phi i32 [ 0, %2 ], [ %24, %22 ]
%8 = tail call signext i8 @fgetc(i32* %1)
switch i8 %8, label %22 [
i8 10, label %9
i8 0, label %9
i8 32, label %15
]
9: ; preds = %5, %5
%10 = sext i32 %6 to i64
%11 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %10
store i8 0, i8* %11
%12 = call i32 @atoi(i8* %4)
%13 = sext i32 %7 to i64
%14 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %12, i32* %14
ret void
15: ; preds = %5
%16 = sext i32 %6 to i64
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %16
store i8 0, i8* %17
%18 = call i32 @atoi(i8* %4)
%19 = sext i32 %7 to i64
%20 = getelementptr inbounds i32, i32* %0, i64 %19
store i32 %18, i32* %20
%21 = add nsw i32 %7, 1
br label %22
22: ; preds = %5, %15
%23 = phi i32 [ 0, %15 ], [ %6, %5 ]
%24 = phi i32 [ %21, %15 ], [ %7, %5 ]
%25 = sext i32 %23 to i64
%26 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %25
store i8 %8, i8* %26
%27 = add nsw i32 %23, 1
br label %5
}