#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 */
char *malloc(int);
char *generate_buffer(int size) {
  char *buf;
  int i;
  buf = malloc(size);
  if (buf == NULL) {
    return NULL;
  }
  for (i = 0; i < size; ++i) {
    buf[i] = (i % 2 == 0) ? 'l' : 'o';
  }
  return buf;
}


x86 assembly (clang, -O0):
<generate_buffer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    113f <generate_buffer+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    1190 <generate_buffer+0x80>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1188 <generate_buffer+0x78>
mov    -0x1c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    $0x6f,%eax
mov    $0x6c,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1146 <generate_buffer+0x36>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_buffer>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
call   1030 <malloc@plt>
test   %rax,%rax
je     156c <generate_buffer+0x45c>
test   %ebx,%ebx
jle    156c <generate_buffer+0x45c>
mov    %ebx,%ecx
cmp    $0x10,%ebx
jae    113b <generate_buffer+0x2b>
xor    %edx,%edx
jmp    1550 <generate_buffer+0x440>
mov    %ecx,%edx
and    $0xfffffff0,%edx
lea    -0x10(%rdx),%rdi
mov    %rdi,%rsi
shr    $0x4,%rsi
add    $0x1,%rsi
mov    %esi,%ebx
and    $0x3,%ebx
cmp    $0x30,%rdi
jae    11a6 <generate_buffer+0x96>
movdqa 0xe9e(%rip),%xmm2
movdqa 0xea6(%rip),%xmm5
movdqa 0xeae(%rip),%xmm0
movdqa 0xeb5(%rip),%xmm14
movdqa 0xebc(%rip),%xmm8
movdqa 0xec3(%rip),%xmm15
movdqa 0xeca(%rip),%xmm9
movdqa 0xed1(%rip),%xmm12
xor    %edi,%edi
jmp    1383 <generate_buffer+0x273>
and    $0xfffffffffffffffc,%rsi
movdqa 0xe4e(%rip),%xmm2
movdqa 0xe56(%rip),%xmm5
movdqa 0xe5e(%rip),%xmm0
movdqa 0xe65(%rip),%xmm14
movdqa 0xe6c(%rip),%xmm8
movdqa 0xe73(%rip),%xmm15
movdqa 0xe7a(%rip),%xmm9
movdqa 0xe81(%rip),%xmm12
xor    %edi,%edi
movdqa 0xe86(%rip),%xmm11
pxor   %xmm10,%xmm10
movdqa 0xe88(%rip),%xmm13
nopl   0x0(%rax,%rax,1)
movdqa %xmm2,%xmm1
pand   %xmm11,%xmm1
movdqa %xmm8,%xmm3
pand   %xmm11,%xmm3
movdqa %xmm9,%xmm6
pand   %xmm11,%xmm6
movdqa %xmm12,%xmm7
pand   %xmm11,%xmm7
pcmpeqd %xmm10,%xmm7
pshufd $0xb1,%xmm7,%xmm4
pand   %xmm13,%xmm7
pand   %xmm4,%xmm7
pcmpeqd %xmm10,%xmm6
pshufd $0xb1,%xmm6,%xmm4
pand   %xmm13,%xmm6
pand   %xmm4,%xmm6
movdqa %xmm15,%xmm4
pand   %xmm11,%xmm4
packuswb %xmm6,%xmm7
pcmpeqd %xmm10,%xmm4
pshufd $0xb1,%xmm4,%xmm6
pand   %xmm13,%xmm4
pand   %xmm6,%xmm4
pcmpeqd %xmm10,%xmm3
pshufd $0xb1,%xmm3,%xmm6
pand   %xmm13,%xmm3
pand   %xmm6,%xmm3
movdqa %xmm0,%xmm6
pand   %xmm11,%xmm6
packuswb %xmm3,%xmm4
movdqa %xmm14,%xmm3
pand   %xmm11,%xmm3
packuswb %xmm7,%xmm7
packuswb %xmm4,%xmm4
packuswb %xmm4,%xmm7
pcmpeqd %xmm10,%xmm3
pshufd $0xb1,%xmm3,%xmm4
pand   %xmm13,%xmm3
pand   %xmm4,%xmm3
pcmpeqd %xmm10,%xmm6
pshufd $0xb1,%xmm6,%xmm4
pand   %xmm13,%xmm6
pand   %xmm4,%xmm6
movdqa %xmm5,%xmm4
pand   %xmm11,%xmm4
packuswb %xmm6,%xmm3
pcmpeqd %xmm10,%xmm4
pshufd $0xb1,%xmm4,%xmm6
pand   %xmm13,%xmm4
pand   %xmm6,%xmm4
pcmpeqd %xmm10,%xmm1
pshufd $0xb1,%xmm1,%xmm6
pand   %xmm13,%xmm1
pand   %xmm6,%xmm1
packuswb %xmm1,%xmm4
packuswb %xmm3,%xmm3
packuswb %xmm4,%xmm1
packuswb %xmm1,%xmm3
shufps $0xcc,%xmm3,%xmm7
movaps %xmm7,%xmm1
andnps 0xd75(%rip),%xmm1
andps  0xd7e(%rip),%xmm7
orps   %xmm1,%xmm7
movups %xmm7,(%rax,%rdi,1)
movups %xmm7,0x10(%rax,%rdi,1)
movups %xmm7,0x20(%rax,%rdi,1)
movups %xmm7,0x30(%rax,%rdi,1)
add    $0x40,%rdi
movdqa 0xd6c(%rip),%xmm1
paddq  %xmm1,%xmm12
paddq  %xmm1,%xmm9
paddq  %xmm1,%xmm15
paddq  %xmm1,%xmm8
paddq  %xmm1,%xmm14
paddq  %xmm1,%xmm0
paddq  %xmm1,%xmm5
paddq  %xmm1,%xmm2
add    $0xfffffffffffffffc,%rsi
jne    1210 <generate_buffer+0x100>
test   %rbx,%rbx
je     1540 <generate_buffer+0x430>
mov    %rax,%rsi
add    %rdi,%rsi
shl    $0x4,%rbx
xor    %edi,%edi
movdqa 0xcdf(%rip),%xmm10
pxor   %xmm13,%xmm13
cs nopw 0x0(%rax,%rax,1)
movdqa %xmm2,(%rsp)
movdqa %xmm2,%xmm1
pand   %xmm10,%xmm1
movdqa %xmm8,%xmm4
pand   %xmm10,%xmm4
movdqa %xmm9,%xmm3
pand   %xmm10,%xmm3
movdqa %xmm12,%xmm7
pand   %xmm10,%xmm7
pcmpeqd %xmm13,%xmm7
pshufd $0xb1,%xmm7,%xmm6
movdqa %xmm8,%xmm2
movdqa %xmm14,%xmm8
movdqa 0xc97(%rip),%xmm14
pand   %xmm14,%xmm7
pand   %xmm6,%xmm7
pcmpeqd %xmm13,%xmm3
pshufd $0xb1,%xmm3,%xmm6
pand   %xmm14,%xmm3
pand   %xmm6,%xmm3
movdqa %xmm15,%xmm6
pand   %xmm10,%xmm6
packuswb %xmm3,%xmm7
pcmpeqd %xmm13,%xmm6
pshufd $0xb1,%xmm6,%xmm3
pand   %xmm14,%xmm6
pand   %xmm3,%xmm6
pcmpeqd %xmm13,%xmm4
pshufd $0xb1,%xmm4,%xmm3
pand   %xmm14,%xmm4
pand   %xmm3,%xmm4
movdqa %xmm0,%xmm3
pand   %xmm10,%xmm3
packuswb %xmm4,%xmm6
movdqa %xmm8,%xmm11
pand   %xmm10,%xmm11
packuswb %xmm7,%xmm7
packuswb %xmm6,%xmm4
packuswb %xmm4,%xmm7
pcmpeqd %xmm13,%xmm11
pshufd $0xb1,%xmm11,%xmm4
pand   %xmm14,%xmm11
pand   %xmm4,%xmm11
pcmpeqd %xmm13,%xmm3
pshufd $0xb1,%xmm3,%xmm4
pand   %xmm14,%xmm3
pand   %xmm4,%xmm3
movdqa %xmm5,%xmm4
pand   %xmm10,%xmm4
packuswb %xmm3,%xmm11
pcmpeqd %xmm13,%xmm4
pshufd $0xb1,%xmm4,%xmm3
pand   %xmm14,%xmm4
pand   %xmm3,%xmm4
pcmpeqd %xmm13,%xmm1
pshufd $0xb1,%xmm1,%xmm3
pand   %xmm14,%xmm1
movdqa %xmm8,%xmm14
movdqa %xmm2,%xmm8
movdqa (%rsp),%xmm2
pand   %xmm3,%xmm1
packuswb %xmm1,%xmm4
packuswb %xmm11,%xmm11
packuswb %xmm4,%xmm1
packuswb %xmm1,%xmm11
shufps $0xcc,%xmm11,%xmm7
movaps %xmm7,%xmm1
andnps 0xba8(%rip),%xmm1
andps  0xbb1(%rip),%xmm7
orps   %xmm1,%xmm7
movups %xmm7,(%rsi,%rdi,1)
movdqa 0xbc2(%rip),%xmm1
paddq  %xmm1,%xmm12
paddq  %xmm1,%xmm9
paddq  %xmm1,%xmm15
paddq  %xmm1,%xmm8
paddq  %xmm1,%xmm14
paddq  %xmm1,%xmm0
paddq  %xmm1,%xmm5
paddq  %xmm1,%xmm2
add    $0x10,%rdi
cmp    %rdi,%rbx
jne    13b0 <generate_buffer+0x2a0>
cmp    %rcx,%rdx
je     156c <generate_buffer+0x45c>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %esi,%esi
test   $0x1,%dl
setne  %sil
lea    (%rsi,%rsi,2),%esi
add    $0x6c,%esi
mov    %sil,(%rax,%rdx,1)
add    $0x1,%rdx
cmp    %rdx,%rcx
jne    1550 <generate_buffer+0x440>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i8* @generate_buffer(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i32 %0, i32* %3
%6 = load i32, i32* %3
%7 = call i8* @malloc(i32 %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i8* null, i8** %2
br label %32
11: ; preds = %1
store i32 0, i32* %5
br label %12
12: ; preds = %27, %11
%13 = load i32, i32* %5
%14 = load i32, i32* %3
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %30
16: ; preds = %12
%17 = load i32, i32* %5
%18 = srem i32 %17, 2
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 108, i32 111
%22 = trunc i32 %21 to i8
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
br label %27
27: ; preds = %16
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
store i32 %29, i32* %5
br label %12
30: ; preds = %12
%31 = load i8*, i8** %4
store i8* %31, i8** %2
br label %32
32: ; preds = %30, %10
%33 = load i8*, i8** %2
ret i8* %33
}

LLVM IR (-O2):
define noalias i8* @generate_buffer(i32 %0) {
%2 = tail call i8* @malloc(i32 %0)
%3 = icmp ne i8* %2, null
%4 = icmp sgt i32 %0, 0
%5 = and i1 %3, %4
br i1 %5, label %6, label %78
6: ; preds = %1
%7 = zext i32 %0 to i64
%8 = icmp ult i32 %0, 16
br i1 %8, label %68, label %9
9: ; preds = %6
%10 = and i64 %7, 4294967280
%11 = add nsw i64 %10, -16
%12 = lshr exact i64 %11, 4
%13 = add nuw nsw i64 %12, 1
%14 = and i64 %13, 3
%15 = icmp ult i64 %11, 48
br i1 %15, label %49, label %16
16: ; preds = %9
%17 = and i64 %13, 2305843009213693948
br label %18
18: ; preds = %18, %16
%19 = phi i64 [ 0, %16 ], [ %45, %18 ]
%20 = phi <16 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>, %16 ], [ %46, %18 ]
%21 = phi i64 [ 0, %16 ], [ %47, %18 ]
%22 = and <16 x i64> %20, <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1>
%23 = icmp eq <16 x i64> %22, zeroinitializer
%24 = select <16 x i1> %23, <16 x i8> <i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108>, <16 x i8> <i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111>
%25 = getelementptr inbounds i8, i8* %2, i64 %19
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> %24, <16 x i8>* %26
%27 = or i64 %19, 16
%28 = and <16 x i64> %20, <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1>
%29 = icmp eq <16 x i64> %28, zeroinitializer
%30 = select <16 x i1> %29, <16 x i8> <i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108>, <16 x i8> <i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111>
%31 = getelementptr inbounds i8, i8* %2, i64 %27
%32 = bitcast i8* %31 to <16 x i8>*
store <16 x i8> %30, <16 x i8>* %32
%33 = or i64 %19, 32
%34 = and <16 x i64> %20, <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1>
%35 = icmp eq <16 x i64> %34, zeroinitializer
%36 = select <16 x i1> %35, <16 x i8> <i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108>, <16 x i8> <i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111>
%37 = getelementptr inbounds i8, i8* %2, i64 %33
%38 = bitcast i8* %37 to <16 x i8>*
store <16 x i8> %36, <16 x i8>* %38
%39 = or i64 %19, 48
%40 = and <16 x i64> %20, <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1>
%41 = icmp eq <16 x i64> %40, zeroinitializer
%42 = select <16 x i1> %41, <16 x i8> <i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108>, <16 x i8> <i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111>
%43 = getelementptr inbounds i8, i8* %2, i64 %39
%44 = bitcast i8* %43 to <16 x i8>*
store <16 x i8> %42, <16 x i8>* %44
%45 = add nuw i64 %19, 64
%46 = add <16 x i64> %20, <i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64, i64 64>
%47 = add i64 %21, 4
%48 = icmp eq i64 %47, %17
br i1 %48, label %49, label %18
49: ; preds = %18, %9
%50 = phi i64 [ 0, %9 ], [ %45, %18 ]
%51 = phi <16 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>, %9 ], [ %46, %18 ]
%52 = icmp eq i64 %14, 0
br i1 %52, label %66, label %53
53: ; preds = %49, %53
%54 = phi i64 [ %62, %53 ], [ %50, %49 ]
%55 = phi <16 x i64> [ %63, %53 ], [ %51, %49 ]
%56 = phi i64 [ %64, %53 ], [ 0, %49 ]
%57 = and <16 x i64> %55, <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1>
%58 = icmp eq <16 x i64> %57, zeroinitializer
%59 = select <16 x i1> %58, <16 x i8> <i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108, i8 108>, <16 x i8> <i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111, i8 111>
%60 = getelementptr inbounds i8, i8* %2, i64 %54
%61 = bitcast i8* %60 to <16 x i8>*
store <16 x i8> %59, <16 x i8>* %61
%62 = add nuw i64 %54, 16
%63 = add <16 x i64> %55, <i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16, i64 16>
%64 = add i64 %56, 1
%65 = icmp eq i64 %64, %14
br i1 %65, label %66, label %53
66: ; preds = %53, %49
%67 = icmp eq i64 %10, %7
br i1 %67, label %78, label %68
68: ; preds = %6, %66
%69 = phi i64 [ 0, %6 ], [ %10, %66 ]
br label %70
70: ; preds = %68, %70
%71 = phi i64 [ %76, %70 ], [ %69, %68 ]
%72 = and i64 %71, 1
%73 = icmp eq i64 %72, 0
%74 = select i1 %73, i8 108, i8 111
%75 = getelementptr inbounds i8, i8* %2, i64 %71
store i8 %74, i8* %75
%76 = add nuw nsw i64 %71, 1
%77 = icmp eq i64 %76, %7
br i1 %77, label %78, label %70
78: ; preds = %70, %66, %1
ret i8* %2
}