#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 symbol {
  int dummy;
};
struct gstr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ str_append(struct gstr *, char const *);
int /*<<< orphan*/ str_printf(struct gstr *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ sym_get_string_value(struct symbol *);
void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str) {
  str_append((struct gstr *)data, str);
  if (sym)
    str_printf((struct gstr *)data, " [=%s]", sym_get_string_value(sym));
}


x86 assembly (clang, -O0):
<expr_print_gstr_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <str_append@plt>
cmpq   $0x0,-0x10(%rbp)
je     117f <expr_print_gstr_helper+0x4f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <sym_get_string_value@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe86(%rip),%rsi
call   1050 <str_printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expr_print_gstr_helper>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rdx,%rsi
call   1040 <str_append@plt>
test   %rbx,%rbx
je     1167 <expr_print_gstr_helper+0x37>
mov    %rbx,%rdi
call   1030 <sym_get_string_value@plt>
lea    0xeaa(%rip),%rsi
mov    %r14,%rdi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <str_printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.symbol = type { i32 }
%struct.gstr = type { i32 }
@.str = [7 x i8] c" [=%s]\00"
define void @expr_print_gstr_helper(i8* %0, %struct.symbol* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca %struct.symbol*
%6 = alloca i8*
store i8* %0, i8** %4
store %struct.symbol* %1, %struct.symbol** %5
store i8* %2, i8** %6
%7 = load i8*, i8** %4
%8 = bitcast i8* %7 to %struct.gstr*
%9 = load i8*, i8** %6
%10 = call i32 @str_append(%struct.gstr* %8, i8* %9)
%11 = load %struct.symbol*, %struct.symbol** %5
%12 = icmp ne %struct.symbol* %11, null
br i1 %12, label %13, label %19
13: ; preds = %3
%14 = load i8*, i8** %4
%15 = bitcast i8* %14 to %struct.gstr*
%16 = load %struct.symbol*, %struct.symbol** %5
%17 = call i32 @sym_get_string_value(%struct.symbol* %16)
%18 = call i32 @str_printf(%struct.gstr* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %13, %3
ret void
}

LLVM IR (-O2):
%struct.symbol = type { i32 }
%struct.gstr = type { i32 }
@.str = [7 x i8] c" [=%s]\00"
define void @expr_print_gstr_helper(i8* %0, %struct.symbol* %1, i8* %2) {
%4 = bitcast i8* %0 to %struct.gstr*
%5 = tail call i32 @str_append(%struct.gstr* %4, i8* %2)
%6 = icmp eq %struct.symbol* %1, null
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i32 @sym_get_string_value(%struct.symbol* %1)
%9 = tail call i32 @str_printf(%struct.gstr* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %3
ret void
}