#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*/ printf(char *);
void print_buffer(int *sbuff) {
  int i = 0;
  for (i = 0; i < 10; ++i) {
    if (sbuff[i] == 1)
      printf("1");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jge    1165 <print_buffer+0x55>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jne    1152 <print_buffer+0x42>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
jmp    1157 <print_buffer+0x47>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    112a <print_buffer+0x1a>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_buffer>:
push   %rbx
mov    %rdi,%rbx
cmpl   $0x1,(%rdi)
je     1178 <print_buffer+0x68>
cmpl   $0x1,0x4(%rbx)
je     1188 <print_buffer+0x78>
cmpl   $0x1,0x8(%rbx)
je     1198 <print_buffer+0x88>
cmpl   $0x1,0xc(%rbx)
je     11a8 <print_buffer+0x98>
cmpl   $0x1,0x10(%rbx)
je     11bc <print_buffer+0xac>
cmpl   $0x1,0x14(%rbx)
je     11d0 <print_buffer+0xc0>
cmpl   $0x1,0x18(%rbx)
je     11e4 <print_buffer+0xd4>
cmpl   $0x1,0x1c(%rbx)
je     11f8 <print_buffer+0xe8>
cmpl   $0x1,0x20(%rbx)
je     120c <print_buffer+0xfc>
cmpl   $0x1,0x24(%rbx)
jne    116d <print_buffer+0x5d>
mov    $0x31,%edi
call   1030 <putchar@plt>
mov    $0xa,%edi
pop    %rbx
jmp    1030 <putchar@plt>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x4(%rbx)
jne    111f <print_buffer+0xf>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x8(%rbx)
jne    1125 <print_buffer+0x15>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0xc(%rbx)
jne    112b <print_buffer+0x1b>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x10(%rbx)
jne    1135 <print_buffer+0x25>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x14(%rbx)
jne    113f <print_buffer+0x2f>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x18(%rbx)
jne    1149 <print_buffer+0x39>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x1c(%rbx)
jne    1153 <print_buffer+0x43>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x20(%rbx)
jne    115d <print_buffer+0x4d>
mov    $0x31,%edi
call   1030 <putchar@plt>
cmpl   $0x1,0x24(%rbx)
je     1163 <print_buffer+0x53>
jmp    116d <print_buffer+0x5d>

LLVM IR (-O0):
@.str = [2 x i8] c"1\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_buffer(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %3
br label %4
4: ; preds = %17, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 10
br i1 %6, label %7, label %20
7: ; preds = %4
%8 = load i32*, i32** %2
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %8, i64 %10
%12 = load i32, i32* %11
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %14, %7
br label %17
17: ; preds = %16
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
store i32 %19, i32* %3
br label %4
20: ; preds = %4
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
define void @print_buffer(i32* nocapture %0) {
%2 = load i32, i32* %0
%3 = icmp eq i32 %2, 1
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @putchar(i32 49)
br label %6
6: ; preds = %1, %4
%7 = getelementptr inbounds i32, i32* %0, i64 1
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @putchar(i32 49)
br label %12
12: ; preds = %10, %6
%13 = getelementptr inbounds i32, i32* %0, i64 2
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call i32 @putchar(i32 49)
br label %18
18: ; preds = %16, %12
%19 = getelementptr inbounds i32, i32* %0, i64 3
%20 = load i32, i32* %19
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = tail call i32 @putchar(i32 49)
br label %24
24: ; preds = %22, %18
%25 = getelementptr inbounds i32, i32* %0, i64 4
%26 = load i32, i32* %25
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %30
28: ; preds = %24
%29 = tail call i32 @putchar(i32 49)
br label %30
30: ; preds = %28, %24
%31 = getelementptr inbounds i32, i32* %0, i64 5
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 1
br i1 %33, label %34, label %36
34: ; preds = %30
%35 = tail call i32 @putchar(i32 49)
br label %36
36: ; preds = %34, %30
%37 = getelementptr inbounds i32, i32* %0, i64 6
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %36
%41 = tail call i32 @putchar(i32 49)
br label %42
42: ; preds = %40, %36
%43 = getelementptr inbounds i32, i32* %0, i64 7
%44 = load i32, i32* %43
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = tail call i32 @putchar(i32 49)
br label %48
48: ; preds = %46, %42
%49 = getelementptr inbounds i32, i32* %0, i64 8
%50 = load i32, i32* %49
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %54
52: ; preds = %48
%53 = tail call i32 @putchar(i32 49)
br label %54
54: ; preds = %52, %48
%55 = getelementptr inbounds i32, i32* %0, i64 9
%56 = load i32, i32* %55
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %60
58: ; preds = %54
%59 = tail call i32 @putchar(i32 49)
br label %60
60: ; preds = %58, %54
%61 = tail call i32 @putchar(i32 10)
ret void
}