#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*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usage(int /*<<< orphan*/, char *, int /*<<< orphan*/);
void process_args(int *argc, char ***argv) {
  char *a0 = (*argv)[0];
  for (int ch; (ch = getopt(*argc, *argv, "h")) != -1;) {
    switch (ch) {
    case 'h':
      usage(stdout, a0, EXIT_SUCCESS);
      break;
    case '?':
    default:
      usage(stderr, a0, EXIT_FAILURE);
    }
  }
  *argc -= optind;
  *argv += optind;
}


x86 assembly (clang, -O0):
<process_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeae(%rip),%rdx
call   1040 <getopt@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
je     11cd <process_args+0xad>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x3f,%eax
je     11a8 <process_args+0x88>
jmp    1177 <process_args+0x57>
mov    -0x20(%rbp),%eax
sub    $0x68,%eax
jne    11ad <process_args+0x8d>
jmp    1188 <process_args+0x68>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    0x2e24(%rip),%rax
mov    (%rax),%edx
call   1030 <usage@plt>
jmp    11c8 <process_args+0xa8>
jmp    11ad <process_args+0x8d>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    0x2e0f(%rip),%rax
mov    (%rax),%edx
call   1030 <usage@plt>
jmp    113e <process_args+0x1e>
mov    0x2e14(%rip),%rax
mov    (%rax),%rdx
mov    -0x8(%rbp),%rax
movslq (%rax),%rcx
sub    %rdx,%rcx
mov    %ecx,(%rax)
mov    0x2dfe(%rip),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
shl    $0x3,%rcx
add    (%rax),%rcx
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rsi),%rsi
mov    (%rsi),%rbx
lea    0xec2(%rip),%r12
mov    0x2e7b(%rip),%r13
mov    0x2e7c(%rip),%rbp
jmp    115f <process_args+0x3f>
xchg   %ax,%ax
mov    (%rcx),%edi
mov    (%rdx),%edx
mov    %rbx,%rsi
call   1030 <usage@plt>
mov    (%r14),%rsi
mov    (%r15),%edi
mov    %r12,%rdx
call   1040 <getopt@plt>
mov    %rbp,%rcx
mov    %r13,%rdx
cmp    $0x68,%eax
je     1150 <process_args+0x30>
cmp    $0xffffffff,%eax
je     118a <process_args+0x6a>
mov    0x2e57(%rip),%rcx
mov    0x2e48(%rip),%rdx
jmp    1150 <process_args+0x30>
mov    0x2e57(%rip),%rax
mov    (%rax),%rax
sub    %eax,(%r15)
shl    $0x3,%rax
add    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"h\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@optind = global i64 0
define void @process_args(i32* %0, i8*** %1) {
%3 = alloca i32*
%4 = alloca i8***
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
store i8*** %1, i8**** %4
%7 = load i8***, i8**** %4
%8 = load i8**, i8*** %7
%9 = getelementptr inbounds i8*, i8** %8, i64 0
%10 = load i8*, i8** %9
store i8* %10, i8** %5
br label %11
11: ; preds = %31, %2
%12 = load i32*, i32** %3
%13 = load i32, i32* %12
%14 = load i8***, i8**** %4
%15 = load i8**, i8*** %14
%16 = call i32 @getopt(i32 %13, i8** %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 %16, i32* %6
%17 = icmp ne i32 %16, -1
br i1 %17, label %18, label %32
18: ; preds = %11
%19 = load i32, i32* %6
switch i32 %19, label %26 [
i32 104, label %20
i32 63, label %25
]
20: ; preds = %18
%21 = load i32, i32* @stdout
%22 = load i8*, i8** %5
%23 = load i32, i32* @EXIT_SUCCESS
%24 = call i32 @usage(i32 %21, i8* %22, i32 %23)
br label %31
25: ; preds = %18
br label %26
26: ; preds = %18, %25
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %5
%29 = load i32, i32* @EXIT_FAILURE
%30 = call i32 @usage(i32 %27, i8* %28, i32 %29)
br label %31
31: ; preds = %26, %20
br label %11
32: ; preds = %11
%33 = load i64, i64* @optind
%34 = load i32*, i32** %3
%35 = load i32, i32* %34
%36 = sext i32 %35 to i64
%37 = sub nsw i64 %36, %33
%38 = trunc i64 %37 to i32
store i32 %38, i32* %34
%39 = load i64, i64* @optind
%40 = load i8***, i8**** %4
%41 = load i8**, i8*** %40
%42 = getelementptr inbounds i8*, i8** %41, i64 %39
store i8** %42, i8*** %40
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"h\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@EXIT_FAILURE = global i32 0
@optind = global i64 0
define void @process_args(i32* nocapture %0, i8*** nocapture %1) {
%3 = load i8**, i8*** %1
%4 = load i8*, i8** %3
br label %5
5: ; preds = %17, %2
%6 = phi i8** [ %23, %17 ], [ %3, %2 ]
%7 = load i32, i32* %0
%8 = tail call i32 @getopt(i32 %7, i8** %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
switch i32 %8, label %16 [
i32 -1, label %9
i32 104, label %17
]
9: ; preds = %5
%10 = load i64, i64* @optind
%11 = load i32, i32* %0
%12 = trunc i64 %10 to i32
%13 = sub i32 %11, %12
store i32 %13, i32* %0
%14 = load i8**, i8*** %1
%15 = getelementptr inbounds i8*, i8** %14, i64 %10
store i8** %15, i8*** %1
ret void
16: ; preds = %5
br label %17
17: ; preds = %5, %16
%18 = phi i32* [ @stderr, %16 ], [ @stdout, %5 ]
%19 = phi i32* [ @EXIT_FAILURE, %16 ], [ @EXIT_SUCCESS, %5 ]
%20 = load i32, i32* %18
%21 = load i32, i32* %19
%22 = tail call i32 @usage(i32 %20, i8* %4, i32 %21)
%23 = load i8**, i8*** %1
br label %5
}