#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*/ write_scc_data(char);
int _write(int dev, void *buf, unsigned int len) {
  int i;
  char *string = (char *)buf;
  for (i = 0; i < len; i++) {
    int j;
    for (j = 0; j < 5000; j++)
      ;
    write_scc_data(string[i]);
  }
  return len;
}


x86 assembly (clang, -O0):
<_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1183 <_write+0x73>
movl   $0x0,-0x24(%rbp)
cmpl   $0x1388,-0x24(%rbp)
jge    1164 <_write+0x54>
jmp    1156 <_write+0x46>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1144 <_write+0x34>
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <write_scc_data@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1131 <_write+0x21>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_write>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
test   %edx,%edx
je     1143 <_write+0x33>
mov    %rsi,%r15
mov    %r14d,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1030 <write_scc_data@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1130 <_write+0x20>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @_write(i32 %0, i8* nocapture %1, i32 returned %2) {
%4 = icmp eq i32 %2, 0
br i1 %4, label %14, label %5
5: ; preds = %3
%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* %1, i64 %8
%10 = load i8, i8* %9
%11 = tail call i32 @write_scc_data(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, %3
ret i32 %2
}