#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 */
int /*<<< orphan*/ EX_USAGE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *);
char *search(char *, char *);
int /*<<< orphan*/ usage(char *);
int main(int ac, char **av) {
  if (ac != 4) {
    usage(av[0]);
    exit(EX_USAGE);
  }
  const char *value = search(av[1], av[3]);
  if (value) {
    printf("%s\n", value);
  } else {
    printf("%s\n", av[2]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     117a <main+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1050 <usage@plt>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
call   1040 <search@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11b3 <main+0x73>
mov    -0x18(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
jmp    11c7 <main+0x87>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe3e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    117b <main+0x3b>
mov    0x8(%rbx),%rdi
mov    0x18(%rbx),%rsi
call   1040 <search@plt>
test   %rax,%rax
je     1167 <main+0x27>
lea    0xe9e(%rip),%rdi
mov    %rax,%rsi
jmp    1172 <main+0x32>
mov    0x10(%rbx),%rsi
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    (%rbx),%rdi
call   1050 <usage@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@EX_USAGE = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp ne i32 %7, 4
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @usage(i8* %12)
%14 = load i32, i32* @EX_USAGE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i8* @search(i8* %19, i8* %22)
store i8* %23, i8** %6
%24 = load i8*, i8** %6
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %29
26: ; preds = %16
%27 = load i8*, i8** %6
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %27)
br label %34
29: ; preds = %16
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %32)
br label %34
34: ; preds = %29, %26
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@EX_USAGE = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @usage(i8* %5)
%7 = load i32, i32* @EX_USAGE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 3
%13 = load i8*, i8** %12
%14 = tail call i8* @search(i8* %11, i8* %13)
%15 = icmp eq i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %9
%17 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %22
18: ; preds = %9
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %18, %16
ret i32 0
}