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

/* Variables and functions */
int /*<<< orphan*/ putchar(char);
char *string_buffer_get_chars(struct string_buffer *);
int string_buffer_get_length(struct string_buffer *);
void print_string_buffer(struct string_buffer *buffer) {
  int n = string_buffer_get_length(buffer);
  char *pcs = string_buffer_get_chars(buffer);
  int i;
  for (i = 0; i < n; i++) {
    putchar(pcs[i]);
  }
}


x86 assembly (clang, -O0):
<print_string_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <string_buffer_get_length@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <string_buffer_get_chars@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1187 <print_string_buffer+0x57>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <putchar@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <print_string_buffer+0x2c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_string_buffer>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <string_buffer_get_length@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <string_buffer_get_chars@plt>
test   %ebp,%ebp
jle    1173 <print_string_buffer+0x43>
mov    %rax,%r14
mov    %ebp,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <print_string_buffer+0x30>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.string_buffer = type { i32 }
define void @print_string_buffer(%struct.string_buffer* %0) {
%2 = alloca %struct.string_buffer*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store %struct.string_buffer* %0, %struct.string_buffer** %2
%6 = load %struct.string_buffer*, %struct.string_buffer** %2
%7 = call i32 @string_buffer_get_length(%struct.string_buffer* %6)
store i32 %7, i32* %3
%8 = load %struct.string_buffer*, %struct.string_buffer** %2
%9 = call i8* @string_buffer_get_chars(%struct.string_buffer* %8)
store i8* %9, i8** %4
store i32 0, i32* %5
br label %10
10: ; preds = %21, %1
%11 = load i32, i32* %5
%12 = load i32, i32* %3
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %24
14: ; preds = %10
%15 = load i8*, i8** %4
%16 = load i32, i32* %5
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = call i32 @putchar(i8 signext %19)
br label %21
21: ; preds = %14
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %10
24: ; preds = %10
ret void
}

LLVM IR (-O2):
%struct.string_buffer = type { i32 }
define void @print_string_buffer(%struct.string_buffer* %0) {
%2 = tail call i32 @string_buffer_get_length(%struct.string_buffer* %0)
%3 = tail call i8* @string_buffer_get_chars(%struct.string_buffer* %0)
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %14
5: ; preds = %1
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %12, %7 ]
%9 = getelementptr inbounds i8, i8* %3, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @putchar(i8 signext %10)
%12 = add nuw nsw i64 %8, 1
%13 = icmp eq i64 %12, %6
br i1 %13, label %14, label %7
14: ; preds = %7, %1
ret void
}