#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 */
scalar_t__ atoi(char *);
char **cfgread(int /*<<< orphan*/ *);
int read_config_lines(FILE *cfp, unsigned short *ptr) {
  char **args;
  int cntr;
  for (cntr = 0;; cntr++) {
    if (!(args = cfgread(cfp)))
      break;
    if (ptr)
      ptr[cntr] = (unsigned short)atoi(args[0]);
  }
  return (cntr);
}


x86 assembly (clang, -O0):
<read_config_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <cfgread@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1153 <read_config_lines+0x33>
jmp    118c <read_config_lines+0x6c>
cmpq   $0x0,-0x10(%rbp)
je     1179 <read_config_lines+0x59>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <atoi@plt>
mov    %ax,%dx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
jmp    117e <read_config_lines+0x5e>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <read_config_lines+0x17>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_config_lines>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
call   1040 <cfgread@plt>
xor    %ebx,%ebx
jmp    114c <read_config_lines+0x2c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
mov    %r14,%rdi
call   1040 <cfgread@plt>
test   %rax,%rax
je     1165 <read_config_lines+0x45>
test   %r15,%r15
je     1140 <read_config_lines+0x20>
mov    (%rax),%rdi
call   1030 <atoi@plt>
mov    %ax,(%r15,%rbx,2)
jmp    1140 <read_config_lines+0x20>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @read_config_lines(i32* %0, i16* %1) {
%3 = alloca i32*
%4 = alloca i16*
%5 = alloca i8**
%6 = alloca i32
store i32* %0, i32** %3
store i16* %1, i16** %4
store i32 0, i32* %6
br label %7
7: ; preds = %26, %2
%8 = load i32*, i32** %3
%9 = call i8** @cfgread(i32* %8)
store i8** %9, i8*** %5
%10 = icmp ne i8** %9, null
br i1 %10, label %12, label %11
11: ; preds = %7
br label %29
12: ; preds = %7
%13 = load i16*, i16** %4
%14 = icmp ne i16* %13, null
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i64 @atoi(i8* %18)
%20 = trunc i64 %19 to i16
%21 = load i16*, i16** %4
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i16, i16* %21, i64 %23
store i16 %20, i16* %24
br label %25
25: ; preds = %15, %12
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %7
29: ; preds = %11
%30 = load i32, i32* %6
ret i32 %30
}

LLVM IR (-O2):
define i32 @read_config_lines(i32* %0, i16* writeonly %1) {
%3 = tail call i8** @cfgread(i32* %0)
%4 = icmp eq i8** %3, null
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = icmp eq i16* %1, null
br label %7
7: ; preds = %5, %15
%8 = phi i64 [ 0, %5 ], [ %16, %15 ]
%9 = phi i8** [ %3, %5 ], [ %17, %15 ]
br i1 %6, label %15, label %10
10: ; preds = %7
%11 = load i8*, i8** %9
%12 = tail call i64 @atoi(i8* %11)
%13 = trunc i64 %12 to i16
%14 = getelementptr inbounds i16, i16* %1, i64 %8
store i16 %13, i16* %14
br label %15
15: ; preds = %7, %10
%16 = add nuw i64 %8, 1
%17 = tail call i8** @cfgread(i32* %0)
%18 = icmp eq i8** %17, null
br i1 %18, label %19, label %7
19: ; preds = %15
%20 = trunc i64 %16 to i32
br label %21
21: ; preds = %19, %2
%22 = phi i32 [ 0, %2 ], [ %20, %19 ]
ret i32 %22
}