#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 */
struct option {
  int dummy;
};

/* Variables and functions */
int gt_print(char *, ...);
int option_option(struct option *, int, char **);
int /*<<< orphan*/ option_usage(struct option *, int);
int option(struct option *opts, int argc, char **argv) {
  int ret = option_option(opts, argc, argv);
  if (ret == argc)
    return 0;
  if (ret < 0 || ret + 1 >= argc)
    return 1;
  gt_print("option `%s' is unknown\n", argv[ret + 1]);
  int slen = gt_print("usage: %s", argv[0]);
  if (slen > 40) {
    slen = 12;
    gt_print("\n%*s", slen, "");
  }
  option_usage(opts, slen);
  gt_print("\n");
  return 1;
}


x86 assembly (clang, -O0):
<option>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <option_option@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    116e <option+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    1214 <option+0xe4>
cmpl   $0x0,-0x24(%rbp)
jl     1187 <option+0x57>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cmp    -0x14(%rbp),%eax
jl     1193 <option+0x63>
movl   $0x1,-0x4(%rbp)
jmp    1214 <option+0xe4>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <gt_print@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <gt_print@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x28,-0x28(%rbp)
jle    11f3 <option+0xc3>
movl   $0xc,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe3d(%rip),%rdi
lea    0xe2b(%rip),%rdx
mov    $0x0,%al
call   1050 <gt_print@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
call   1030 <option_usage@plt>
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1050 <gt_print@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<option>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
call   1040 <option_option@plt>
xor    %r15d,%r15d
cmp    %ebp,%eax
je     11bf <option+0x8f>
mov    $0x1,%r15d
test   %eax,%eax
js     11bf <option+0x8f>
add    $0x1,%eax
cmp    %ebp,%eax
jge    11bf <option+0x8f>
mov    %eax,%eax
mov    (%rbx,%rax,8),%rsi
lea    0xe97(%rip),%rdi
xor    %eax,%eax
call   1050 <gt_print@plt>
mov    (%rbx),%rsi
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1050 <gt_print@plt>
mov    %eax,%ebx
cmp    $0x29,%eax
jl     11a7 <option+0x77>
lea    0xe93(%rip),%rdi
lea    0xe81(%rip),%rdx
mov    $0xc,%ebx
mov    $0xc,%esi
xor    %eax,%eax
call   1050 <gt_print@plt>
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <option_usage@plt>
lea    0xe5e(%rip),%rdi
xor    %eax,%eax
call   1050 <gt_print@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i32 }
@.str = [24 x i8] c"option `%s' is unknown\0A\00"
@.str.1 = [10 x i8] c"usage: %s\00"
@.str.2 = [5 x i8] c"\0A%*s\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c"\0A\00"
define i32 @option(%struct.option* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca %struct.option*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store %struct.option* %0, %struct.option** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
%10 = load %struct.option*, %struct.option** %5
%11 = load i32, i32* %6
%12 = load i8**, i8*** %7
%13 = call i32 @option_option(%struct.option* %10, i32 %11, i8** %12)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = load i32, i32* %6
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %18
17: ; preds = %3
store i32 0, i32* %4
br label %49
18: ; preds = %3
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %18
%22 = load i32, i32* %8
%23 = add nsw i32 %22, 1
%24 = load i32, i32* %6
%25 = icmp sge i32 %23, %24
br i1 %25, label %26, label %27
26: ; preds = %21, %18
store i32 1, i32* %4
br label %49
27: ; preds = %21
%28 = load i8**, i8*** %7
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8*, i8** %28, i64 %31
%33 = load i8*, i8** %32
%34 = call i32 (i8*, ...) @gt_print(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %33)
%35 = load i8**, i8*** %7
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 (i8*, ...) @gt_print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %37)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = icmp sgt i32 %39, 40
br i1 %40, label %41, label %44
41: ; preds = %27
store i32 12, i32* %9
%42 = load i32, i32* %9
%43 = call i32 (i8*, ...) @gt_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %42, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %44
44: ; preds = %41, %27
%45 = load %struct.option*, %struct.option** %5
%46 = load i32, i32* %9
%47 = call i32 @option_usage(%struct.option* %45, i32 %46)
%48 = call i32 (i8*, ...) @gt_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %4
br label %49
49: ; preds = %44, %26, %17
%50 = load i32, i32* %4
ret i32 %50
}

LLVM IR (-O2):
%struct.option = type { i32 }
@.str = [24 x i8] c"option `%s' is unknown\0A\00"
@.str.1 = [10 x i8] c"usage: %s\00"
@.str.2 = [5 x i8] c"\0A%*s\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [2 x i8] c"\0A\00"
define i32 @option(%struct.option* %0, i32 %1, i8** %2) {
%4 = tail call i32 @option_option(%struct.option* %0, i32 %1, i8** %2)
%5 = icmp eq i32 %4, %1
br i1 %5, label %25, label %6
6: ; preds = %3
%7 = icmp slt i32 %4, 0
br i1 %7, label %25, label %8
8: ; preds = %6
%9 = add nuw nsw i32 %4, 1
%10 = icmp slt i32 %9, %1
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = zext i32 %9 to i64
%13 = getelementptr inbounds i8*, i8** %2, i64 %12
%14 = load i8*, i8** %13
%15 = tail call i32 (i8*, ...) @gt_print(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i8*, i8** %2
%17 = tail call i32 (i8*, ...) @gt_print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = icmp sgt i32 %17, 40
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = tail call i32 (i8*, ...) @gt_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %19, %11
%22 = phi i32 [ 12, %19 ], [ %17, %11 ]
%23 = tail call i32 @option_usage(%struct.option* %0, i32 %22)
%24 = tail call i32 (i8*, ...) @gt_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %25
25: ; preds = %6, %8, %3, %21
%26 = phi i32 [ 1, %21 ], [ 0, %3 ], [ 1, %8 ], [ 1, %6 ]
ret i32 %26
}