#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*/ EBADF;
#define STDERR_FILENO 129
#define STDOUT_FILENO 128
int /*<<< orphan*/ errno;
int _write(int file, char *ptr, int len) {
  if (ptr) {
  }
  int n;
  switch (file) {
  case STDOUT_FILENO:
    for (n = 0; n < len; n++) {
    }
    break;
  case STDERR_FILENO:
    for (n = 0; n < len; n++) {
    }
    break;
  default:
    errno = EBADF;
    return -1;
  }
  return len;
}


x86 assembly (clang, -O0):
<_write>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     111e <_write+0x1e>
jmp    111e <_write+0x1e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x80,%eax
je     1147 <_write+0x47>
jmp    1134 <_write+0x34>
mov    -0x1c(%rbp),%eax
sub    $0x81,%eax
je     1172 <_write+0x72>
jmp    119d <_write+0x9d>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116d <_write+0x6d>
jmp    115f <_write+0x5f>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    114e <_write+0x4e>
jmp    11bb <_write+0xbb>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1198 <_write+0x98>
jmp    118a <_write+0x8a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1179 <_write+0x79>
jmp    11bb <_write+0xbb>
mov    0x2e34(%rip),%rax
mov    (%rax),%ecx
mov    0x2e33(%rip),%rax
mov    %ecx,(%rax)
movl   $0xffffffff,-0x4(%rbp)
jmp    11c1 <_write+0xc1>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_write>:
mov    %edx,%eax
and    $0xfffffffe,%edi
cmp    $0x80,%edi
je     1124 <_write+0x24>
mov    0x2ec4(%rip),%rax
mov    (%rax),%eax
mov    0x2ec3(%rip),%rcx
mov    %eax,(%rcx)
mov    $0xffffffff,%eax
ret

LLVM IR (-O0):
@EBADF = global i32 0
@errno = global i32 0
define i32 @_write(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %6
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %12
11: ; preds = %3
br label %12
12: ; preds = %11, %3
%13 = load i32, i32* %5
switch i32 %13, label %34 [
i32 128, label %14
i32 129, label %24
]
14: ; preds = %12
store i32 0, i32* %8
br label %15
15: ; preds = %20, %14
%16 = load i32, i32* %8
%17 = load i32, i32* %7
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %23
19: ; preds = %15
br label %20
20: ; preds = %19
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
br label %15
23: ; preds = %15
br label %36
24: ; preds = %12
store i32 0, i32* %8
br label %25
25: ; preds = %30, %24
%26 = load i32, i32* %8
%27 = load i32, i32* %7
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %33
29: ; preds = %25
br label %30
30: ; preds = %29
%31 = load i32, i32* %8
%32 = add nsw i32 %31, 1
store i32 %32, i32* %8
br label %25
33: ; preds = %25
br label %36
34: ; preds = %12
%35 = load i32, i32* @EBADF
store i32 %35, i32* @errno
store i32 -1, i32* %4
br label %38
36: ; preds = %33, %23
%37 = load i32, i32* %7
store i32 %37, i32* %4
br label %38
38: ; preds = %36, %34
%39 = load i32, i32* %4
ret i32 %39
}

LLVM IR (-O2):
@EBADF = global i32 0
@errno = global i32 0
define i32 @_write(i32 %0, i8* nocapture readnone %1, i32 %2) {
%4 = and i32 %0, -2
%5 = icmp eq i32 %4, 128
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = load i32, i32* @EBADF
store i32 %7, i32* @errno
br label %8
8: ; preds = %3, %6
%9 = phi i32 [ -1, %6 ], [ %2, %3 ]
ret i32 %9
}