#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 ini_file {
  int dummy;
};

/* Variables and functions */
int ini__append_new_section(struct ini_file *, char const *);
char *ini__to_lower(char *);
size_t strlen(char *);
int ini__parse_section(struct ini_file *self, char *str) {
  size_t len = strlen(str);
  char *end = str + len - 1;
  if (*str != '[' || *end != ']')
    return -1;
  *end = '\0';
  const char *name = ini__to_lower(str + 1);
  return ini__append_new_section(self, name);
}


x86 assembly (clang, -O0):
<ini__parse_section>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5b,%eax
jne    117d <ini__parse_section+0x4d>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5d,%eax
je     1189 <ini__parse_section+0x59>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <ini__parse_section+0x81>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1050 <ini__to_lower@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <ini__append_new_section@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ini__parse_section>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
cmpb   $0x5b,(%rbx)
jne    1171 <ini__parse_section+0x41>
cmpb   $0x5d,-0x1(%rbx,%rax,1)
jne    1171 <ini__parse_section+0x41>
movb   $0x0,-0x1(%rbx,%rax,1)
add    $0x1,%rbx
mov    %rbx,%rdi
call   1050 <ini__to_lower@plt>
mov    %r14,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <ini__append_new_section@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.ini_file = type { i32 }
define i32 @ini__parse_section(%struct.ini_file* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.ini_file*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
store %struct.ini_file* %0, %struct.ini_file** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
store i64 %10, i64* %6
%11 = load i8*, i8** %5
%12 = load i64, i64* %6
%13 = getelementptr inbounds i8, i8* %11, i64 %12
%14 = getelementptr inbounds i8, i8* %13, i64 -1
store i8* %14, i8** %7
%15 = load i8*, i8** %5
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 91
br i1 %18, label %24, label %19
19: ; preds = %2
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 93
br i1 %23, label %24, label %25
24: ; preds = %19, %2
store i32 -1, i32* %3
br label %33
25: ; preds = %19
%26 = load i8*, i8** %7
store i8 0, i8* %26
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = call i8* @ini__to_lower(i8* %28)
store i8* %29, i8** %8
%30 = load %struct.ini_file*, %struct.ini_file** %4
%31 = load i8*, i8** %8
%32 = call i32 @ini__append_new_section(%struct.ini_file* %30, i8* %31)
store i32 %32, i32* %3
br label %33
33: ; preds = %25, %24
%34 = load i32, i32* %3
ret i32 %34
}

LLVM IR (-O2):
%struct.ini_file = type { i32 }
define i32 @ini__parse_section(%struct.ini_file* %0, i8* %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = getelementptr inbounds i8, i8* %1, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -1
%6 = load i8, i8* %1
%7 = icmp eq i8 %6, 91
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i8, i8* %5
%10 = icmp eq i8 %9, 93
br i1 %10, label %11, label %15
11: ; preds = %8
store i8 0, i8* %5
%12 = getelementptr inbounds i8, i8* %1, i64 1
%13 = tail call i8* @ini__to_lower(i8* %12)
%14 = tail call i32 @ini__append_new_section(%struct.ini_file* %0, i8* %13)
br label %15
15: ; preds = %2, %8, %11
%16 = phi i32 [ %14, %11 ], [ -1, %8 ], [ -1, %2 ]
ret i32 %16
}