#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[1]);
  }
  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    118d <read_config_lines+0x6d>
cmpq   $0x0,-0x10(%rbp)
je     117a <read_config_lines+0x5a>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atoi@plt>
mov    %ax,%dx
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dx,(%rax,%rcx,2)
jmp    117f <read_config_lines+0x5f>
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     1166 <read_config_lines+0x46>
test   %r15,%r15
je     1140 <read_config_lines+0x20>
mov    0x8(%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 1
%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 %22, label %5
5: ; preds = %2
%6 = icmp eq i16* %1, null
br label %7
7: ; preds = %5, %16
%8 = phi i64 [ 0, %5 ], [ %17, %16 ]
%9 = phi i8** [ %3, %5 ], [ %18, %16 ]
br i1 %6, label %16, label %10
10: ; preds = %7
%11 = getelementptr inbounds i8*, i8** %9, i64 1
%12 = load i8*, i8** %11
%13 = tail call i64 @atoi(i8* %12)
%14 = trunc i64 %13 to i16
%15 = getelementptr inbounds i16, i16* %1, i64 %8
store i16 %14, i16* %15
br label %16
16: ; preds = %7, %10
%17 = add nuw i64 %8, 1
%18 = tail call i8** @cfgread(i32* %0)
%19 = icmp eq i8** %18, null
br i1 %19, label %20, label %7
20: ; preds = %16
%21 = trunc i64 %17 to i32
br label %22
22: ; preds = %20, %2
%23 = phi i32 [ 0, %2 ], [ %21, %20 ]
ret i32 %23
}