#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*/ dieNeg(int, char *);
int rand();
int write(int, unsigned char *, int);
void multimode(int fd, int count) {
  int i, ret;
  for (i = 0; i < count; ++i) {
    unsigned char byte = rand() & 077;
    ret = write(fd, &byte, 1);
    dieNeg(ret, "multimode write");
  }
}


x86 assembly (clang, -O0):
<multimode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118f <multimode+0x5f>
mov    $0x0,%al
call   1050 <rand@plt>
and    $0x3f,%eax
mov    %al,-0x11(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
lea    0xe84(%rip),%rsi
call   1040 <dieNeg@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1145 <multimode+0x15>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<multimode>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    117b <multimode+0x4b>
mov    %esi,%ebx
mov    %edi,%ebp
lea    0x7(%rsp),%r14
lea    0xeb5(%rip),%r15
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <rand@plt>
and    $0x3f,%al
mov    %al,0x7(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,%edi
mov    %r15,%rsi
call   1040 <dieNeg@plt>
add    $0xffffffff,%ebx
jne    1150 <multimode+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [16 x i8] c"multimode write\00"
define void @multimode(i32 %0, i32 %1) {
%3 = alloca i8
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %14
5: ; preds = %2, %5
%6 = phi i32 [ %12, %5 ], [ 0, %2 ]
%7 = tail call i32 (...) @rand()
%8 = trunc i32 %7 to i8
%9 = and i8 %8, 63
store i8 %9, i8* %3
%10 = call i32 @write(i32 %0, i8* %3, i32 1)
%11 = tail call i32 @dieNeg(i32 %10, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%12 = add nuw nsw i32 %6, 1
%13 = icmp eq i32 %12, %1
br i1 %13, label %14, label %5
14: ; preds = %5, %2
ret void
}