#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 */
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int a_val;
};
struct TYPE_5__ {
  int a_type;
  TYPE_1__ a_un;
};
typedef TYPE_2__ Elf32_auxv_t;

/* Variables and functions */
int AT_NULL;
int /*<<< orphan*/ write_string(char *);
int get_aux_val(Elf32_auxv_t *aux, int t) {
  int i;
  for (i = 0; aux[i].a_type != AT_NULL; i++)
    if (aux[i].a_type == t)
      return aux[i].a_un.a_val;
  write_string("Not found\n");
  return 0;
}


x86 assembly (clang, -O0):
<get_aux_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
mov    0x2ea0(%rip),%rcx
cmp    (%rcx),%eax
je     117b <get_aux_val+0x6b>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%eax
cmp    -0x14(%rbp),%eax
jne    1168 <get_aux_val+0x58>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    0x4(%rax,%rcx,8),%eax
mov    %eax,-0x4(%rbp)
jmp    118e <get_aux_val+0x7e>
jmp    116d <get_aux_val+0x5d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <get_aux_val+0x16>
lea    0xe7e(%rip),%rdi
call   1030 <write_string@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_aux_val>:
push   %rax
mov    0x2ec0(%rip),%rax
mov    (%rax),%eax
mov    (%rdi),%edx
cmp    %eax,%edx
je     1140 <get_aux_val+0x30>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    %esi,%edx
je     1150 <get_aux_val+0x40>
mov    0x8(%rdi,%rcx,8),%edx
add    $0x1,%rcx
cmp    %eax,%edx
jne    1130 <get_aux_val+0x20>
lea    0xeb9(%rip),%rdi
call   1030 <write_string@plt>
xor    %eax,%eax
pop    %rcx
ret
mov    %ecx,%eax
mov    0x4(%rdi,%rax,8),%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@AT_NULL = global i32 0
@.str = [11 x i8] c"Not found\0A\00"
define i32 @get_aux_val(%struct.TYPE_5__* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_5__*
%5 = alloca i32
%6 = alloca i32
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %4
store i32 %1, i32* %5
store i32 0, i32* %6
br label %7
7: ; preds = %34, %2
%8 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%9 = load i32, i32* %6
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %8, i64 %10
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load i32, i32* @AT_NULL
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %37
16: ; preds = %7
%17 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i64 %19
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load i32, i32* %5
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %33
25: ; preds = %16
%26 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %26, i64 %28
%30 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %29, i32 0, i32 1
%31 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %30, i32 0, i32 0
%32 = load i32, i32* %31
store i32 %32, i32* %3
br label %39
33: ; preds = %16
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %7
37: ; preds = %7
%38 = call i32 @write_string(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %39
39: ; preds = %37, %25
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32 }
@AT_NULL = global i32 0
@.str = [11 x i8] c"Not found\0A\00"
define i32 @get_aux_val(%struct.TYPE_5__* nocapture %0, i32 %1) {
%3 = load i32, i32* @AT_NULL
%4 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, %3
br i1 %6, label %20, label %7
7: ; preds = %2, %15
%8 = phi i64 [ %16, %15 ], [ 0, %2 ]
%9 = phi i32 [ %18, %15 ], [ %5, %2 ]
%10 = icmp eq i32 %9, %1
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = and i64 %8, 4294967295
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 %12, i32 1, i32 0
%14 = load i32, i32* %13
br label %22
15: ; preds = %7
%16 = add nuw i64 %8, 1
%17 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 %16, i32 0
%18 = load i32, i32* %17
%19 = icmp eq i32 %18, %3
br i1 %19, label %20, label %7
20: ; preds = %15, %2
%21 = tail call i32 @write_string(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %11
%23 = phi i32 [ %14, %11 ], [ 0, %20 ]
ret i32 %23
}