#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*/ log_err(char *, int, char *);
scalar_t__ strcmp(char *, char *);
char *strsep(char **, char *);
short conf_ini_check_section(char *str, int line) {
  char *sections[] = {NULL, "global", "cmd", "hooks", "forward", "transmit"};
  short i;
  char *name;
  str++;
  name = strsep(&str, "]");
  for (i = 1; i < 6; i++) {
    if (strcmp(name, sections[i]) == 0) {
      return i;
    }
  }
  log_err("[c] invalid section declaration line %i: %s\n", line, name);
  return 0;
}


x86 assembly (clang, -O0):
<conf_ini_check_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1030 <memset@plt>
lea    0xe9a(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe96(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe8f(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe87(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <strsep@plt>
mov    %rax,-0x60(%rbp)
movw   $0x1,-0x52(%rbp)
movswl -0x52(%rbp),%eax
cmp    $0x6,%eax
jge    1209 <conf_ini_check_section+0xc9>
mov    -0x60(%rbp),%rdi
movswq -0x52(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11f3 <conf_ini_check_section+0xb3>
mov    -0x52(%rbp),%ax
mov    %ax,-0x2(%rbp)
jmp    1222 <conf_ini_check_section+0xe2>
jmp    11f8 <conf_ini_check_section+0xb8>
mov    -0x52(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x52(%rbp)
jmp    11bc <conf_ini_check_section+0x7c>
mov    -0x14(%rbp),%esi
mov    -0x60(%rbp),%rdx
lea    0xe0d(%rip),%rdi
call   1060 <log_err@plt>
movw   $0x0,-0x2(%rbp)
movswl -0x2(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<conf_ini_check_section>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
add    $0x1,%rdi
mov    %rdi,(%rsp)
lea    0xede(%rip),%rsi
mov    %rsp,%rdi
call   1040 <strsep@plt>
mov    %rax,%rbx
lea    0xeaa(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11c8 <conf_ini_check_section+0x98>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ce <conf_ini_check_section+0x9e>
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d4 <conf_ini_check_section+0xa4>
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11da <conf_ini_check_section+0xaa>
lea    0xe73(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11e0 <conf_ini_check_section+0xb0>
lea    0xe6a(%rip),%rdi
mov    %ebp,%esi
mov    %rbx,%rdx
call   1050 <log_err@plt>
xor    %eax,%eax
jmp    11e4 <conf_ini_check_section+0xb4>
mov    $0x1,%ax
jmp    11e4 <conf_ini_check_section+0xb4>
mov    $0x2,%ax
jmp    11e4 <conf_ini_check_section+0xb4>
mov    $0x3,%ax
jmp    11e4 <conf_ini_check_section+0xb4>
mov    $0x4,%ax
jmp    11e4 <conf_ini_check_section+0xb4>
mov    $0x5,%ax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"global\00"
@.str.1 = [4 x i8] c"cmd\00"
@.str.2 = [6 x i8] c"hooks\00"
@.str.3 = [8 x i8] c"forward\00"
@.str.4 = [9 x i8] c"transmit\00"
@.str.5 = [2 x i8] c"]\00"
@.str.6 = [45 x i8] c"[c] invalid section declaration line %i: %s\0A\00"
define signext i16 @conf_ini_check_section(i8* %0, i32 %1) {
%3 = alloca i16
%4 = alloca i8*
%5 = alloca i32
%6 = alloca [6 x i8*]
%7 = alloca i16
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = bitcast [6 x i8*]* %6 to i8*
%10 = bitcast i8* %9 to [6 x i8*]*
%11 = getelementptr inbounds [6 x i8*], [6 x i8*]* %10, i32 0, i32 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [6 x i8*], [6 x i8*]* %10, i32 0, i32 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i32 0, i32 0), i8** %12
%13 = getelementptr inbounds [6 x i8*], [6 x i8*]* %10, i32 0, i32 3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i32 0, i32 0), i8** %13
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* %10, i32 0, i32 4
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i32 0, i32 0), i8** %14
%15 = getelementptr inbounds [6 x i8*], [6 x i8*]* %10, i32 0, i32 5
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i32 0, i32 0), i8** %15
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i32 1
store i8* %17, i8** %4
%18 = call i8* @strsep(i8** %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i8* %18, i8** %8
store i16 1, i16* %7
br label %19
19: ; preds = %34, %2
%20 = load i16, i16* %7
%21 = sext i16 %20 to i32
%22 = icmp slt i32 %21, 6
br i1 %22, label %23, label %37
23: ; preds = %19
%24 = load i8*, i8** %8
%25 = load i16, i16* %7
%26 = sext i16 %25 to i64
%27 = getelementptr inbounds [6 x i8*], [6 x i8*]* %6, i64 0, i64 %26
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %24, i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %23
%32 = load i16, i16* %7
store i16 %32, i16* %3
br label %41
33: ; preds = %23
br label %34
34: ; preds = %33
%35 = load i16, i16* %7
%36 = add i16 %35, 1
store i16 %36, i16* %7
br label %19
37: ; preds = %19
%38 = load i32, i32* %5
%39 = load i8*, i8** %8
%40 = call i32 @log_err(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %38, i8* %39)
store i16 0, i16* %3
br label %41
41: ; preds = %37, %31
%42 = load i16, i16* %3
ret i16 %42
}

LLVM IR (-O2):
@.str = [7 x i8] c"global\00"
@.str.1 = [4 x i8] c"cmd\00"
@.str.2 = [6 x i8] c"hooks\00"
@.str.3 = [8 x i8] c"forward\00"
@.str.4 = [9 x i8] c"transmit\00"
@.str.5 = [2 x i8] c"]\00"
@.str.6 = [45 x i8] c"[c] invalid section declaration line %i: %s\0A\00"
define signext i16 @conf_ini_check_section(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = getelementptr inbounds i8, i8* %0, i64 1
store i8* %4, i8** %3
%5 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %2
%9 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %22, label %11
11: ; preds = %8
%12 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %11
%15 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %22, label %17
17: ; preds = %14
%18 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %17
%21 = call i32 @log_err(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.6, i64 0, i64 0), i32 %1, i8* %5)
br label %22
22: ; preds = %2, %8, %11, %14, %17, %20
%23 = phi i16 [ 0, %20 ], [ 1, %2 ], [ 2, %8 ], [ 3, %11 ], [ 4, %14 ], [ 5, %17 ]
ret i16 %23
}