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

/* Variables and functions */
int /*<<< orphan*/ first_in_dynamic(struct cfg_t *);
int /*<<< orphan*/ in_static(struct cfg_t *);
int /*<<< orphan*/ next_dynamic_section(struct cfg_t *);
int read_character(struct cfg_t *, char *);
int /*<<< orphan*/ write_static(struct cfg_t *, char);
void have_opening_bracket(struct cfg_t *cfg) {
  char character;
  if (read_character(cfg, &character) < 1) {
    return;
  }

  if (character == '[') {
    next_dynamic_section(cfg);
    first_in_dynamic(cfg);
  } else {
    write_static(cfg, '[');
    write_static(cfg, character);
    in_static(cfg);
  }
  return;
}


x86 assembly (clang, -O0):
<have_opening_bracket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x9(%rbp),%rsi
call   1050 <read_character@plt>
cmp    $0x1,%eax
jge    1177 <have_opening_bracket+0x27>
jmp    11c4 <have_opening_bracket+0x74>
movsbl -0x9(%rbp),%eax
cmp    $0x5b,%eax
jne    119b <have_opening_bracket+0x4b>
mov    -0x8(%rbp),%rdi
call   1030 <next_dynamic_section@plt>
mov    -0x8(%rbp),%rdi
call   1060 <first_in_dynamic@plt>
jmp    11bf <have_opening_bracket+0x6f>
mov    -0x8(%rbp),%rdi
mov    $0x5b,%esi
call   1040 <write_static@plt>
mov    -0x8(%rbp),%rdi
movsbl -0x9(%rbp),%esi
call   1040 <write_static@plt>
mov    -0x8(%rbp),%rdi
call   1070 <in_static@plt>
jmp    11c4 <have_opening_bracket+0x74>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<have_opening_bracket>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xf(%rsp),%rsi
call   1050 <read_character@plt>
test   %eax,%eax
jle    11a1 <have_opening_bracket+0x51>
cmpb   $0x5b,0xf(%rsp)
jne    117f <have_opening_bracket+0x2f>
mov    %rbx,%rdi
call   1030 <next_dynamic_section@plt>
mov    %rbx,%rdi
call   1060 <first_in_dynamic@plt>
jmp    11a1 <have_opening_bracket+0x51>
mov    %rbx,%rdi
mov    $0x5b,%esi
call   1040 <write_static@plt>
movsbl 0xf(%rsp),%esi
mov    %rbx,%rdi
call   1040 <write_static@plt>
mov    %rbx,%rdi
call   1070 <in_static@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.cfg_t = type { i32 }
define void @have_opening_bracket(%struct.cfg_t* %0) {
%2 = alloca %struct.cfg_t*
%3 = alloca i8
store %struct.cfg_t* %0, %struct.cfg_t** %2
%4 = load %struct.cfg_t*, %struct.cfg_t** %2
%5 = call i32 @read_character(%struct.cfg_t* %4, i8* %3)
%6 = icmp slt i32 %5, 1
br i1 %6, label %7, label %8
7: ; preds = %1
br label %26
8: ; preds = %1
%9 = load i8, i8* %3
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 91
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = load %struct.cfg_t*, %struct.cfg_t** %2
%14 = call i32 @next_dynamic_section(%struct.cfg_t* %13)
%15 = load %struct.cfg_t*, %struct.cfg_t** %2
%16 = call i32 @first_in_dynamic(%struct.cfg_t* %15)
br label %25
17: ; preds = %8
%18 = load %struct.cfg_t*, %struct.cfg_t** %2
%19 = call i32 @write_static(%struct.cfg_t* %18, i8 signext 91)
%20 = load %struct.cfg_t*, %struct.cfg_t** %2
%21 = load i8, i8* %3
%22 = call i32 @write_static(%struct.cfg_t* %20, i8 signext %21)
%23 = load %struct.cfg_t*, %struct.cfg_t** %2
%24 = call i32 @in_static(%struct.cfg_t* %23)
br label %25
25: ; preds = %17, %12
br label %26
26: ; preds = %25, %7
ret void
}

LLVM IR (-O2):
%struct.cfg_t = type { i32 }
define void @have_opening_bracket(%struct.cfg_t* %0) {
%2 = alloca i8
%3 = call i32 @read_character(%struct.cfg_t* %0, i8* %2)
%4 = icmp slt i32 %3, 1
br i1 %4, label %16, label %5
5: ; preds = %1
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 91
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = call i32 @next_dynamic_section(%struct.cfg_t* %0)
%10 = call i32 @first_in_dynamic(%struct.cfg_t* %0)
br label %16
11: ; preds = %5
%12 = call i32 @write_static(%struct.cfg_t* %0, i8 signext 91)
%13 = load i8, i8* %2
%14 = call i32 @write_static(%struct.cfg_t* %0, i8 signext %13)
%15 = call i32 @in_static(%struct.cfg_t* %0)
br label %16
16: ; preds = %8, %11, %1
ret void
}