char *getnext(cp, argc, argv, swvalid)
char *cp;
int *argc;
char ***argv;
int swvalid;
{
  if (*++cp == '\0') {
    if (*argc != 0) {
      --*argc;
      cp = *++*argv;
    } else
      usage(1);
  }
  if (!swvalid && (*cp == '-'))
    usage(1);
  return (cp);
}


x86 assembly (clang, -O0):
<getnext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    118a <getnext+0x7a>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
je     1179 <getnext+0x69>
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xffffffff,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rcx
mov    (%rcx),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,(%rcx)
mov    0x8(%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1185 <getnext+0x75>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <usage@plt>
jmp    118a <getnext+0x7a>
cmpl   $0x0,-0x1c(%rbp)
jne    11b0 <getnext+0xa0>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    11b0 <getnext+0xa0>
mov    $0x1,%edi
mov    $0x0,%al
call   1030 <usage@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getnext>:
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebp
lea    0x1(%rdi),%rbx
cmpb   $0x0,0x1(%rdi)
jne    1138 <getnext+0x28>
mov    (%rsi),%eax
test   %eax,%eax
je     114f <getnext+0x3f>
add    $0xffffffff,%eax
mov    %eax,(%rsi)
mov    (%rdx),%rax
lea    0x8(%rax),%rcx
mov    %rcx,(%rdx)
mov    0x8(%rax),%rbx
test   %ebp,%ebp
jne    115f <getnext+0x4f>
cmpb   $0x2d,(%rbx)
jne    115f <getnext+0x4f>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <usage@plt>
jmp    115f <getnext+0x4f>
mov    $0x1,%edi
xor    %eax,%eax
call   1030 <usage@plt>
test   %ebp,%ebp
je     113c <getnext+0x2c>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i8* @getnext(i8* %0, i32* %1, i8*** %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8***
%8 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i8*** %2, i8**** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = getelementptr inbounds i8, i8* %9, i32 1
store i8* %10, i8** %5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %29
14: ; preds = %4
%15 = load i32*, i32** %6
%16 = load i32, i32* %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32*, i32** %6
%20 = load i32, i32* %19
%21 = add nsw i32 %20, -1
store i32 %21, i32* %19
%22 = load i8***, i8**** %7
%23 = load i8**, i8*** %22
%24 = getelementptr inbounds i8*, i8** %23, i32 1
store i8** %24, i8*** %22
%25 = load i8*, i8** %24
store i8* %25, i8** %5
br label %28
26: ; preds = %14
%27 = call i32 (i32, ...) bitcast (i32 (...)* @usage to i32 (i32, ...)*)(i32 1)
br label %28
28: ; preds = %26, %18
br label %29
29: ; preds = %28, %4
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, 0
br i1 %31, label %39, label %32
32: ; preds = %29
%33 = load i8*, i8** %5
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 45
br i1 %36, label %37, label %39
37: ; preds = %32
%38 = call i32 (i32, ...) bitcast (i32 (...)* @usage to i32 (i32, ...)*)(i32 1)
br label %39
39: ; preds = %37, %32, %29
%40 = load i8*, i8** %5
ret i8* %40
}

LLVM IR (-O2):
define i8* @getnext(i8* %0, i32* nocapture %1, i8*** nocapture %2, i32 %3) {
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
%7 = icmp eq i8 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %4
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = add nsw i32 %9, -1
store i32 %12, i32* %1
%13 = load i8**, i8*** %2
%14 = getelementptr inbounds i8*, i8** %13, i64 1
store i8** %14, i8*** %2
%15 = load i8*, i8** %14
br label %18
16: ; preds = %8
%17 = tail call i32 (i32, ...) bitcast (i32 (...)* @usage to i32 (i32, ...)*)(i32 1)
br label %18
18: ; preds = %11, %16, %4
%19 = phi i8* [ %15, %11 ], [ %5, %16 ], [ %5, %4 ]
%20 = icmp eq i32 %3, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i8, i8* %19
%23 = icmp eq i8 %22, 45
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 (i32, ...) bitcast (i32 (...)* @usage to i32 (i32, ...)*)(i32 1)
br label %26
26: ; preds = %24, %21, %18
ret i8* %19
}