#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*/ chain_setting(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ table_setting(char *);
int update_setting(char *line) {
  int i, k;
  char str[32];
  i = 0;
  k = 0;
  while (line[i++] == ' ')
    k++;
  sscanf(line, "%s", str);
  if (!strcmp(str, "<Value"))
    table_setting(&line[k]);
  else if (!strcmp(str, "<chain"))
    chain_setting(&line[k]);
  else
    printf("Unknown statement: %s\n", line);
  return 0;
}


x86 assembly (clang, -O0):
<update_setting>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    1197 <update_setting+0x47>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    116a <update_setting+0x1a>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe5a(%rip),%rsi
call   1060 <sscanf@plt>
lea    -0x30(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11d9 <update_setting+0x89>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
call   1040 <table_setting@plt>
jmp    121c <update_setting+0xcc>
lea    -0x30(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    1207 <update_setting+0xb7>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
add    %rax,%rdi
call   1070 <chain_setting@plt>
jmp    1217 <update_setting+0xc7>
mov    -0x8(%rbp),%rsi
lea    0xdff(%rip),%rdi
call   1030 <printf@plt>
jmp    121c <update_setting+0xcc>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_setting>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
cmpb   $0x20,(%rdi)
jne    1170 <update_setting+0x30>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,0x1(%rbx,%rax,1)
lea    0x1(%rax),%rax
je     1160 <update_setting+0x20>
mov    %eax,%r14d
jmp    1173 <update_setting+0x33>
xor    %r14d,%r14d
lea    0xe86(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
mov    $0x6c61563c,%eax
xor    (%rsp),%eax
mov    $0x65756c,%ecx
xor    0x3(%rsp),%ecx
or     %eax,%ecx
je     11c0 <update_setting+0x80>
mov    $0x6168633c,%eax
xor    (%rsp),%eax
mov    $0x6e6961,%ecx
xor    0x3(%rsp),%ecx
or     %eax,%ecx
je     11cd <update_setting+0x8d>
lea    0xe5b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
jmp    11d8 <update_setting+0x98>
add    %r14,%rbx
mov    %rbx,%rdi
call   1040 <table_setting@plt>
jmp    11d8 <update_setting+0x98>
add    %r14,%rbx
mov    %rbx,%rdi
call   1060 <chain_setting@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"<Value\00"
@.str.2 = [7 x i8] c"<chain\00"
@.str.3 = [23 x i8] c"Unknown statement: %s\0A\00"
define i32 @update_setting(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [32 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
br label %6
6: ; preds = %15, %1
%7 = load i8*, i8** %2
%8 = load i32, i32* %3
%9 = add nsw i32 %8, 1
store i32 %9, i32* %3
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 32
br i1 %14, label %15, label %18
15: ; preds = %6
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 1
store i32 %17, i32* %4
br label %6
18: ; preds = %6
%19 = load i8*, i8** %2
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%21 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %31, label %25
25: ; preds = %18
%26 = load i8*, i8** %2
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i32 @table_setting(i8* %29)
br label %45
31: ; preds = %18
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%33 = call i32 @strcmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%34 = icmp ne i32 %33, 0
br i1 %34, label %41, label %35
35: ; preds = %31
%36 = load i8*, i8** %2
%37 = load i32, i32* %4
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = call i32 @chain_setting(i8* %39)
br label %44
41: ; preds = %31
%42 = load i8*, i8** %2
%43 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %42)
br label %44
44: ; preds = %41, %35
br label %45
45: ; preds = %44, %25
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [7 x i8] c"<Value\00"
@.str.2 = [7 x i8] c"<chain\00"
@.str.3 = [23 x i8] c"Unknown statement: %s\0A\00"
define i32 @update_setting(i8* %0) {
%2 = alloca [32 x i8]
%3 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 32
br i1 %5, label %6, label %14
6: ; preds = %1, %6
%7 = phi i64 [ %8, %6 ], [ 0, %1 ]
%8 = add nuw nsw i64 %7, 1
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 32
br i1 %11, label %6, label %12
12: ; preds = %6
%13 = and i64 %8, 4294967295
br label %14
14: ; preds = %12, %1
%15 = phi i64 [ 0, %1 ], [ %13, %12 ]
%16 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%17 = call i32 @bcmp(i8* dereferenceable(7) %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 7)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = getelementptr inbounds i8, i8* %0, i64 %15
%21 = call i32 @table_setting(i8* %20)
br label %30
22: ; preds = %14
%23 = call i32 @bcmp(i8* dereferenceable(7) %3, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 7)
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = getelementptr inbounds i8, i8* %0, i64 %15
%27 = call i32 @chain_setting(i8* %26)
br label %30
28: ; preds = %22
%29 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %30
30: ; preds = %25, %28, %19
ret i32 0
}