#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 */
struct res_sym {
  scalar_t__ name;
  int number;
};

/* Variables and functions */
scalar_t__ strcasecmp(char const *, scalar_t__);
int sym_ston(const struct res_sym *syms, const char *name, int *success) {
  for ((void)NULL; syms->name != 0; syms++) {
    if (strcasecmp(name, syms->name) == 0) {
      if (success)
        *success = 1;
      return (syms->number);
    }
  }
  if (success)
    *success = 0;
  return (syms->number);
}


x86 assembly (clang, -O0):
<sym_ston>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1186 <sym_ston+0x76>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1170 <sym_ston+0x60>
cmpq   $0x0,-0x20(%rbp)
je     1161 <sym_ston+0x51>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <sym_ston+0x95>
jmp    1175 <sym_ston+0x65>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x10(%rbp)
jmp    1124 <sym_ston+0x14>
cmpq   $0x0,-0x20(%rbp)
je     119b <sym_ston+0x8b>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sym_ston>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdi),%rsi
test   %rsi,%rsi
je     114a <sym_ston+0x3a>
cs nopw 0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     115d <sym_ston+0x4d>
mov    0x10(%rbx),%rsi
add    $0x10,%rbx
test   %rsi,%rsi
jne    1130 <sym_ston+0x20>
xor    %eax,%eax
test   %r14,%r14
je     1154 <sym_ston+0x44>
mov    %eax,(%r14)
mov    0x8(%rbx),%eax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x1,%eax
test   %r14,%r14
jne    1151 <sym_ston+0x41>
jmp    1154 <sym_ston+0x44>

LLVM IR (-O0):
%struct.res_sym = type { i64, i32 }
define i32 @sym_ston(%struct.res_sym* %0, i8* %1, i32* %2) {
%4 = alloca i32
%5 = alloca %struct.res_sym*
%6 = alloca i8*
%7 = alloca i32*
store %struct.res_sym* %0, %struct.res_sym** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
br label %8
8: ; preds = %30, %3
%9 = load %struct.res_sym*, %struct.res_sym** %5
%10 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %9, i32 0, i32 0
%11 = load i64, i64* %10
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %33
13: ; preds = %8
%14 = load i8*, i8** %6
%15 = load %struct.res_sym*, %struct.res_sym** %5
%16 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %15, i32 0, i32 0
%17 = load i64, i64* %16
%18 = call i64 @strcasecmp(i8* %14, i64 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %29
20: ; preds = %13
%21 = load i32*, i32** %7
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32*, i32** %7
store i32 1, i32* %24
br label %25
25: ; preds = %23, %20
%26 = load %struct.res_sym*, %struct.res_sym** %5
%27 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %26, i32 0, i32 1
%28 = load i32, i32* %27
store i32 %28, i32* %4
br label %42
29: ; preds = %13
br label %30
30: ; preds = %29
%31 = load %struct.res_sym*, %struct.res_sym** %5
%32 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %31, i32 1
store %struct.res_sym* %32, %struct.res_sym** %5
br label %8
33: ; preds = %8
%34 = load i32*, i32** %7
%35 = icmp ne i32* %34, null
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = load i32*, i32** %7
store i32 0, i32* %37
br label %38
38: ; preds = %36, %33
%39 = load %struct.res_sym*, %struct.res_sym** %5
%40 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %39, i32 0, i32 1
%41 = load i32, i32* %40
store i32 %41, i32* %4
br label %42
42: ; preds = %38, %25
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
%struct.res_sym = type { i64, i32 }
define i32 @sym_ston(%struct.res_sym* nocapture %0, i8* %1, i32* writeonly %2) {
%4 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %0, i64 0, i32 0
%5 = load i64, i64* %4
%6 = icmp eq i64 %5, 0
br i1 %6, label %19, label %7
7: ; preds = %3, %14
%8 = phi i64 [ %17, %14 ], [ %5, %3 ]
%9 = phi %struct.res_sym* [ %15, %14 ], [ %0, %3 ]
%10 = tail call i64 @strcasecmp(i8* %1, i64 %8)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = icmp eq i32* %2, null
br i1 %13, label %25, label %22
14: ; preds = %7
%15 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %9, i64 1
%16 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %15, i64 0, i32 0
%17 = load i64, i64* %16
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %7
19: ; preds = %14, %3
%20 = phi %struct.res_sym* [ %0, %3 ], [ %15, %14 ]
%21 = icmp eq i32* %2, null
br i1 %21, label %25, label %22
22: ; preds = %19, %12
%23 = phi i32 [ 1, %12 ], [ 0, %19 ]
%24 = phi %struct.res_sym* [ %9, %12 ], [ %20, %19 ]
store i32 %23, i32* %2
br label %25
25: ; preds = %22, %19, %12
%26 = phi %struct.res_sym* [ %20, %19 ], [ %9, %12 ], [ %24, %22 ]
%27 = getelementptr inbounds %struct.res_sym, %struct.res_sym* %26, i64 0, i32 1
%28 = load i32, i32* %27
ret i32 %28
}