#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strcmp(char *, char *);
void setargs(char *flag, char *arg, char **query, FILE **out) {
  if (!strcmp(flag, "-q")) {
    *query = arg;
    return;
  }
  if (!strcmp(flag, "--query")) {
    *query = arg;
    return;
  }
  if (!strcmp(flag, "-f")) {
    perror("-f not implemented");
    exit(1);
    return;
  }
  if (!strcmp(flag, "--file")) {
    perror("--file not implemented");
    exit(1);
    return;
  }
  (void)out;
}


x86 assembly (clang, -O0):
<setargs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1171 <setargs+0x41>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11f8 <setargs+0xc8>
mov    -0x8(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    119a <setargs+0x6a>
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
jmp    11f8 <setargs+0xc8>
mov    -0x8(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c9 <setargs+0x99>
lea    0xe54(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11f8 <setargs+0xc8>
lea    0xe3f(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setargs>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xebb(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1190 <setargs+0x60>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1190 <setargs+0x60>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1199 <setargs+0x69>
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
jne    1193 <setargs+0x63>
lea    0xe9a(%rip),%rdi
jmp    11a0 <setargs+0x70>
mov    %r15,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe6e(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-q\00"
@.str.1 = [8 x i8] c"--query\00"
@.str.2 = [3 x i8] c"-f\00"
@.str.3 = [19 x i8] c"-f not implemented\00"
@.str.4 = [7 x i8] c"--file\00"
@.str.5 = [23 x i8] c"--file not implemented\00"
define void @setargs(i8* %0, i8* %1, i8** %2, i32** %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8**
%8 = alloca i32**
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8** %2, i8*** %7
store i32** %3, i32*** %8
%9 = load i8*, i8** %5
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %4
%13 = load i8*, i8** %6
%14 = load i8**, i8*** %7
store i8* %13, i8** %14
br label %38
15: ; preds = %4
%16 = load i8*, i8** %5
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %15
%20 = load i8*, i8** %6
%21 = load i8**, i8*** %7
store i8* %20, i8** %21
br label %38
22: ; preds = %15
%23 = load i8*, i8** %5
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %22
%27 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %22
%30 = load i8*, i8** %5
%31 = call i32 @strcmp(i8* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%32 = icmp ne i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %29
%34 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %29
%37 = load i32**, i32*** %8
br label %38
38: ; preds = %36, %19, %12
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-q\00"
@.str.1 = [8 x i8] c"--query\00"
@.str.2 = [3 x i8] c"-f\00"
@.str.3 = [19 x i8] c"-f not implemented\00"
@.str.4 = [7 x i8] c"--file\00"
@.str.5 = [23 x i8] c"--file not implemented\00"
define void @setargs(i8* nocapture %0, i8* %1, i8** nocapture writeonly %2, i32** nocapture readnone %3) {
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %22, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10
%17 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %7, %4
store i8* %1, i8** %2
br label %23
23: ; preds = %22, %16
ret void
}