#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 *argval(char *);
int /*<<< orphan*/ die(char *, char *);
char *my_strcpy(char *);
char *get_next_argp(char ***argv, char *arg) {
  char *tmp;
  tmp = argval(arg);
  if (!tmp) {
    tmp = *(++(*argv));
    if (tmp)
      tmp = my_strcpy(tmp);
  }
  if (!tmp)
    die("Option %s needs an argument\n", arg);
  return tmp;
}


x86 assembly (clang, -O0):
<get_next_argp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <argval@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    118e <get_next_argp+0x5e>
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,(%rcx)
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1189 <get_next_argp+0x59>
mov    -0x18(%rbp),%rdi
call   1030 <my_strcpy@plt>
mov    %rax,-0x18(%rbp)
jmp    118e <get_next_argp+0x5e>
cmpq   $0x0,-0x18(%rbp)
jne    11a9 <get_next_argp+0x79>
mov    -0x10(%rbp),%rsi
lea    0xe5c(%rip),%rdi
call   1050 <die@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_next_argp>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <argval@plt>
test   %rax,%rax
jne    1175 <get_next_argp+0x45>
mov    (%rbx),%rax
lea    0x8(%rax),%rcx
mov    %rcx,(%rbx)
mov    0x8(%rax),%rdi
test   %rdi,%rdi
je     1164 <get_next_argp+0x34>
call   1030 <my_strcpy@plt>
test   %rax,%rax
jne    1175 <get_next_argp+0x45>
lea    0xe95(%rip),%rdi
mov    %r14,%rsi
call   1050 <die@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Option %s needs an argument\0A\00"
define i8* @get_next_argp(i8*** %0, i8* %1) {
%3 = alloca i8***
%4 = alloca i8*
%5 = alloca i8*
store i8*** %0, i8**** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = call i8* @argval(i8* %6)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %21, label %10
10: ; preds = %2
%11 = load i8***, i8**** %3
%12 = load i8**, i8*** %11
%13 = getelementptr inbounds i8*, i8** %12, i32 1
store i8** %13, i8*** %11
%14 = load i8*, i8** %13
store i8* %14, i8** %5
%15 = load i8*, i8** %5
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = load i8*, i8** %5
%19 = call i8* @my_strcpy(i8* %18)
store i8* %19, i8** %5
br label %20
20: ; preds = %17, %10
br label %21
21: ; preds = %20, %2
%22 = load i8*, i8** %5
%23 = icmp ne i8* %22, null
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i8*, i8** %4
%26 = call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %24, %21
%28 = load i8*, i8** %5
ret i8* %28
}

LLVM IR (-O2):
@.str = [29 x i8] c"Option %s needs an argument\0A\00"
define i8* @get_next_argp(i8*** nocapture %0, i8* %1) {
%3 = tail call i8* @argval(i8* %1)
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = load i8**, i8*** %0
%7 = getelementptr inbounds i8*, i8** %6, i64 1
store i8** %7, i8*** %0
%8 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %13, label %10
10: ; preds = %5
%11 = tail call i8* @my_strcpy(i8* %8)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %15
13: ; preds = %5, %10
%14 = tail call i32 @die(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %15
15: ; preds = %2, %13, %10
%16 = phi i8* [ null, %13 ], [ %11, %10 ], [ %3, %2 ]
ret i8* %16
}