#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 */
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void get_args(char *command, int maxlen, int argc, char **argv) {
  while (--argc > 0) {
    ++argv;
    if (strcmp("-e", *argv) == 0) {
      if (--argc > 0) {
        ++argv;
        strncpy(command, *argv, maxlen);
      }
    }
  }
}


x86 assembly (clang, -O0):
<get_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jle    11ac <get_args+0x8c>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe9e(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a7 <get_args+0x87>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jle    11a2 <get_args+0x82>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
mov    -0xc(%rbp),%edx
call   1030 <strncpy@plt>
jmp    11a7 <get_args+0x87>
jmp    1136 <get_args+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_args>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x2,%edx
jl     118d <get_args+0x6d>
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%r15
lea    0xec1(%rip),%r12
jmp    115c <get_args+0x3c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%ebp
add    $0x8,%rbx
cmp    $0x1,%ebp
jle    118d <get_args+0x6d>
mov    0x8(%rbx),%rsi
mov    %r12,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1150 <get_args+0x30>
cmp    $0x3,%ebp
jb     118d <get_args+0x6d>
add    $0xfffffffe,%ebp
mov    0x10(%rbx),%rsi
add    $0x10,%rbx
mov    %r15,%rdi
mov    %r14d,%edx
call   1030 <strncpy@plt>
cmp    $0x1,%ebp
jg     115c <get_args+0x3c>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-e\00"
define void @get_args(i8* %0, i32 %1, i32 %2, i8** %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8** %3, i8*** %8
br label %9
9: ; preds = %33, %4
%10 = load i32, i32* %7
%11 = add nsw i32 %10, -1
store i32 %11, i32* %7
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %34
13: ; preds = %9
%14 = load i8**, i8*** %8
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %8
%16 = load i8**, i8*** %8
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %33
20: ; preds = %13
%21 = load i32, i32* %7
%22 = add nsw i32 %21, -1
store i32 %22, i32* %7
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load i8**, i8*** %8
%26 = getelementptr inbounds i8*, i8** %25, i32 1
store i8** %26, i8*** %8
%27 = load i8*, i8** %5
%28 = load i8**, i8*** %8
%29 = load i8*, i8** %28
%30 = load i32, i32* %6
%31 = call i32 @strncpy(i8* %27, i8* %29, i32 %30)
br label %32
32: ; preds = %24, %20
br label %33
33: ; preds = %32, %13
br label %9
34: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"-e\00"
define void @get_args(i8* %0, i32 %1, i32 %2, i8** nocapture %3) {
%5 = icmp sgt i32 %2, 1
br i1 %5, label %6, label %25
6: ; preds = %4, %21
%7 = phi i8** [ %23, %21 ], [ %3, %4 ]
%8 = phi i32 [ %22, %21 ], [ %2, %4 ]
%9 = add nsw i32 %8, -1
%10 = getelementptr inbounds i8*, i8** %7, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %6
%15 = icmp ugt i32 %8, 2
br i1 %15, label %16, label %25
16: ; preds = %14
%17 = add nsw i32 %8, -2
%18 = getelementptr inbounds i8*, i8** %7, i64 2
%19 = load i8*, i8** %18
%20 = tail call i32 @strncpy(i8* %0, i8* %19, i32 %1)
br label %21
21: ; preds = %16, %6
%22 = phi i32 [ %17, %16 ], [ %9, %6 ]
%23 = phi i8** [ %18, %16 ], [ %10, %6 ]
%24 = icmp sgt i32 %22, 1
br i1 %24, label %6, label %25
25: ; preds = %14, %21, %4
ret void
}