#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 */

/* Variables and functions */
char *get_line_word(char *, char **);
int strtol(char *, int /*<<< orphan*/ *, int);
int copy_int(void *d, char *next) {
  int *id = (int *)d;
  char *v;
  while ((v = get_line_word(next, &next))) {
    switch (v[0]) {
    case 'y':
    case 'Y':
      *id = 1;
      break;
    case 'n':
    case 'N':
      *id = 0;
      break;
    default:
      *id = strtol(v, NULL, 10);
    }
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<copy_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <get_line_word@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11e2 <copy_int+0xc2>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x4e,%eax
je     11ad <copy_int+0x8d>
jmp    116b <copy_int+0x4b>
mov    -0x2c(%rbp),%eax
sub    $0x59,%eax
je     119e <copy_int+0x7e>
jmp    117c <copy_int+0x5c>
mov    -0x2c(%rbp),%eax
sub    $0x6e,%eax
je     11ad <copy_int+0x8d>
jmp    118d <copy_int+0x6d>
mov    -0x2c(%rbp),%eax
sub    $0x79,%eax
jne    11bc <copy_int+0x9c>
jmp    119e <copy_int+0x7e>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
jmp    11d6 <copy_int+0xb6>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    11d6 <copy_int+0xb6>
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11e9 <copy_int+0xc9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<copy_int>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rax
mov    %rdi,%rbx
mov    %rsi,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1030 <get_line_word@plt>
test   %rax,%rax
je     115b <copy_int+0x3b>
movsbl (%rax),%edx
mov    $0x1,%ecx
cmp    $0x6d,%edx
jg     1162 <copy_int+0x42>
cmp    $0x4e,%edx
je     116c <copy_int+0x4c>
cmp    $0x59,%edx
je     1181 <copy_int+0x61>
jmp    1170 <copy_int+0x50>
mov    $0x1,%eax
jmp    1185 <copy_int+0x65>
cmp    $0x79,%edx
je     1181 <copy_int+0x61>
cmp    $0x6e,%edx
jne    1170 <copy_int+0x50>
xor    %ecx,%ecx
jmp    1181 <copy_int+0x61>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %eax,%ecx
mov    %ecx,(%rbx)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @copy_int(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %4
%9 = bitcast i8* %8 to i32*
store i32* %9, i32** %6
br label %10
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = call i8* @get_line_word(i8* %11, i8** %5)
store i8* %12, i8** %7
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %28
14: ; preds = %10
%15 = load i8*, i8** %7
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
switch i32 %18, label %23 [
i32 121, label %19
i32 89, label %19
i32 110, label %21
i32 78, label %21
]
19: ; preds = %14, %14
%20 = load i32*, i32** %6
store i32 1, i32* %20
br label %27
21: ; preds = %14, %14
%22 = load i32*, i32** %6
store i32 0, i32* %22
br label %27
23: ; preds = %14
%24 = load i8*, i8** %7
%25 = call i32 @strtol(i8* %24, i32* null, i32 10)
%26 = load i32*, i32** %6
store i32 %25, i32* %26
br label %27
27: ; preds = %23, %21, %19
store i32 0, i32* %3
br label %29
28: ; preds = %10
store i32 1, i32* %3
br label %29
29: ; preds = %28, %27
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @copy_int(i8* nocapture writeonly %0, i8* %1) {
%3 = alloca i8*
store i8* %1, i8** %3
%4 = bitcast i8* %0 to i32*
%5 = call i8* @get_line_word(i8* %1, i8** %3)
%6 = icmp eq i8* %5, null
br i1 %6, label %15, label %7
7: ; preds = %2
%8 = load i8, i8* %5
%9 = sext i8 %8 to i32
switch i32 %9, label %11 [
i32 121, label %13
i32 89, label %13
i32 110, label %10
i32 78, label %10
]
10: ; preds = %7, %7
br label %13
11: ; preds = %7
%12 = call i32 @strtol(i8* nocapture %5, i32* null, i32 10)
br label %13
13: ; preds = %7, %7, %11, %10
%14 = phi i32 [ 0, %10 ], [ %12, %11 ], [ 1, %7 ], [ 1, %7 ]
store i32 %14, i32* %4
br label %15
15: ; preds = %13, %2
%16 = phi i32 [ 1, %2 ], [ 0, %13 ]
ret i32 %16
}