#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 */
char *extract_option(char const *, char *, int);
int /*<<< orphan*/ print_changed_options();
scalar_t__ process_option(char *);
int set_options(const char args[]) {
  int err = 0;
  if (*args == '\0') {
    print_changed_options();
    return 0;
  }
  while (*args != '\0') {
    char buf[1024];
    args = extract_option(args, buf, 1);
    if (args == NULL)
      return -1;
    err += process_option(buf);
  }
  return err;
}


x86 assembly (clang, -O0):
<set_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1169 <set_options+0x39>
mov    $0x0,%al
call   1050 <print_changed_options@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d2 <set_options+0xa2>
jmp    116e <set_options+0x3e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cc <set_options+0x9c>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    $0x1,%edx
call   1040 <extract_option@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ae <set_options+0x7e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d2 <set_options+0xa2>
lea    -0x420(%rbp),%rdi
call   1030 <process_option@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
jmp    116e <set_options+0x3e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_options>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
cmpb   $0x0,(%rdi)
je     1179 <set_options+0x49>
mov    %rdi,%rbx
xor    %ebp,%ebp
mov    %rsp,%r14
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <extract_option@plt>
test   %rax,%rax
je     1184 <set_options+0x54>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <process_option@plt>
add    %eax,%ebp
cmpb   $0x0,(%rbx)
jne    1150 <set_options+0x20>
jmp    1189 <set_options+0x59>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <print_changed_options@plt>
jmp    1189 <set_options+0x59>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @set_options(i8* %0) {
%2 = alloca [1024 x i8]
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %1
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %15
7: ; preds = %1
%8 = tail call i32 (...) @print_changed_options()
br label %21
9: ; preds = %15
%10 = call i64 @process_option(i8* %6)
%11 = trunc i64 %10 to i32
%12 = add i32 %16, %11
%13 = load i8, i8* %18
%14 = icmp eq i8 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %5, %9
%16 = phi i32 [ 0, %5 ], [ %12, %9 ]
%17 = phi i8* [ %0, %5 ], [ %18, %9 ]
%18 = call i8* @extract_option(i8* %17, i8* %6, i32 1)
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %9
20: ; preds = %15
br label %21
21: ; preds = %9, %20, %7
%22 = phi i32 [ 0, %7 ], [ -1, %20 ], [ %12, %9 ]
ret i32 %22
}