#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 mode_data {
  int dummy;
};
struct action_entry {
  int dummy;
};

/* Variables and functions */
int parse_sym_mode_arg(char *, struct mode_data **, struct mode_data **);
int parse_sym_mode_args(struct action_entry *action, int args, char **argv,
                        void **data) {
  int i, res = 1;
  struct mode_data *head = NULL, *cur = NULL;
  for (i = 0; i < args && res; i++)
    res = parse_sym_mode_arg(argv[i], &head, &cur);
  *data = head;
  return res;
}


x86 assembly (clang, -O0):
<parse_sym_mode_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x1,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%ecx
xor    %eax,%eax
cmp    -0xc(%rbp),%ecx
mov    %al,-0x39(%rbp)
jge    1160 <parse_sym_mode_args+0x50>
cmpl   $0x0,-0x28(%rbp)
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1170 <parse_sym_mode_args+0x60>
jmp    119a <parse_sym_mode_args+0x8a>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <parse_sym_mode_arg@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1145 <parse_sym_mode_args+0x35>
mov    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_sym_mode_args>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
test   %esi,%esi
jle    1174 <parse_sym_mode_args+0x64>
mov    %rdx,%r13
mov    %esi,%ebx
mov    $0x1,%ebp
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    -0x8(%r13,%rbp,8),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1030 <parse_sym_mode_arg@plt>
cmp    %rbx,%rbp
jae    116d <parse_sym_mode_args+0x5d>
add    $0x1,%rbp
test   %eax,%eax
jne    1150 <parse_sym_mode_args+0x40>
mov    0x8(%rsp),%rcx
jmp    117b <parse_sym_mode_args+0x6b>
mov    $0x1,%eax
xor    %ecx,%ecx
mov    %rcx,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.action_entry = type { i32 }
%struct.mode_data = type { i32 }
define i32 @parse_sym_mode_args(%struct.action_entry* %0, i32 %1, i8** %2, i8** %3) {
%5 = alloca %struct.action_entry*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.mode_data*
%12 = alloca %struct.mode_data*
store %struct.action_entry* %0, %struct.action_entry** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8** %3, i8*** %8
store i32 1, i32* %10
store %struct.mode_data* null, %struct.mode_data** %11
store %struct.mode_data* null, %struct.mode_data** %12
store i32 0, i32* %9
br label %13
13: ; preds = %29, %4
%14 = load i32, i32* %9
%15 = load i32, i32* %6
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %20
17: ; preds = %13
%18 = load i32, i32* %10
%19 = icmp ne i32 %18, 0
br label %20
20: ; preds = %17, %13
%21 = phi i1 [ false, %13 ], [ %19, %17 ]
br i1 %21, label %22, label %32
22: ; preds = %20
%23 = load i8**, i8*** %7
%24 = load i32, i32* %9
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
%27 = load i8*, i8** %26
%28 = call i32 @parse_sym_mode_arg(i8* %27, %struct.mode_data** %11, %struct.mode_data** %12)
store i32 %28, i32* %10
br label %29
29: ; preds = %22
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
store i32 %31, i32* %9
br label %13
32: ; preds = %20
%33 = load %struct.mode_data*, %struct.mode_data** %11
%34 = bitcast %struct.mode_data* %33 to i8*
%35 = load i8**, i8*** %8
store i8* %34, i8** %35
%36 = load i32, i32* %10
ret i32 %36
}

LLVM IR (-O2):
%struct.action_entry = type { i32 }
%struct.mode_data = type { i32 }
define i32 @parse_sym_mode_args(%struct.action_entry* nocapture readnone %0, i32 %1, i8** nocapture %2, i8** nocapture writeonly %3) {
%5 = alloca %struct.mode_data*
%6 = alloca %struct.mode_data*
%7 = bitcast %struct.mode_data** %5 to i8*
store %struct.mode_data* null, %struct.mode_data** %5
%8 = bitcast %struct.mode_data** %6 to i8*
store %struct.mode_data* null, %struct.mode_data** %6
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %24
10: ; preds = %4
%11 = zext i32 %1 to i64
br label %12
12: ; preds = %10, %12
%13 = phi i64 [ 0, %10 ], [ %17, %12 ]
%14 = getelementptr inbounds i8*, i8** %2, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @parse_sym_mode_arg(i8* %15, %struct.mode_data** %5, %struct.mode_data** %6)
%17 = add nuw nsw i64 %13, 1
%18 = icmp ult i64 %17, %11
%19 = icmp ne i32 %16, 0
%20 = select i1 %18, i1 %19, i1 false
br i1 %20, label %12, label %21
21: ; preds = %12
%22 = bitcast %struct.mode_data** %5 to i8**
%23 = load i8*, i8** %22
br label %24
24: ; preds = %4, %21
%25 = phi i8* [ %23, %21 ], [ null, %4 ]
%26 = phi i32 [ %16, %21 ], [ 1, %4 ]
store i8* %25, i8** %3
ret i32 %26
}