#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 */
typedef int uint64_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ close(int);
int syscall(int, int *, int /*<<< orphan*/, int, int, int /*<<< orphan*/);
void sheep(uint32_t off) {
  uint64_t buf[10] = {0x4800000001, off, 0, 0, 0, 0x300};
  int fd = syscall(298, buf, 0, -1, -1, 0);
  assert(!close(fd));
}


x86 assembly (clang, -O0):
<sheep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x30(%rbp),%rcx
movl   $0x1,-0x30(%rbp)
mov    %rcx,%rax
add    $0x4,%rax
mov    -0x4(%rbp),%edx
mov    %edx,-0x2c(%rbp)
add    $0x4,%rax
movl   $0x0,-0x28(%rbp)
add    $0x4,%rax
movl   $0x0,-0x24(%rbp)
add    $0x4,%rax
movl   $0x0,-0x20(%rbp)
add    $0x4,%rax
movl   $0x300,-0x1c(%rbp)
add    $0x4,%rax
add    $0x28,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x48(%rbp),%rcx
movl   $0x0,(%rax)
add    $0x4,%rax
mov    %rax,-0x50(%rbp)
cmp    %rcx,%rax
mov    %rax,-0x40(%rbp)
jne    118f <sheep+0x5f>
lea    -0x30(%rbp),%rsi
mov    $0x12a,%edi
xor    %r9d,%r9d
mov    $0xffffffff,%r8d
mov    %r9d,%edx
mov    %r8d,%ecx
call   1050 <syscall@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1030 <close@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sheep>:
sub    $0x28,%rsp
movl   $0x1,(%rsp)
mov    %edi,0x4(%rsp)
movaps 0xeba(%rip),%xmm0
movups %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x18(%rsp)
mov    %rsp,%rsi
mov    $0x12a,%edi
xor    %edx,%edx
mov    $0xffffffff,%ecx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
call   1050 <syscall@plt>
mov    %eax,%edi
call   1030 <close@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1040 <assert@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
define void @sheep(i32 %0) {
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca i32
store i32 %0, i32* %2
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
store i32 1, i32* %5
%6 = getelementptr inbounds i32, i32* %5, i64 1
%7 = load i32, i32* %2
store i32 %7, i32* %6
%8 = getelementptr inbounds i32, i32* %6, i64 1
store i32 0, i32* %8
%9 = getelementptr inbounds i32, i32* %8, i64 1
store i32 0, i32* %9
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32 0, i32* %10
%11 = getelementptr inbounds i32, i32* %10, i64 1
store i32 768, i32* %11
%12 = getelementptr inbounds i32, i32* %11, i64 1
%13 = getelementptr inbounds i32, i32* %5, i64 10
br label %14
14: ; preds = %14, %1
%15 = phi i32* [ %12, %1 ], [ %16, %14 ]
store i32 0, i32* %15
%16 = getelementptr inbounds i32, i32* %15, i64 1
%17 = icmp eq i32* %16, %13
br i1 %17, label %18, label %14
18: ; preds = %14
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%20 = call i32 @syscall(i32 298, i32* %19, i32 0, i32 -1, i32 -1, i32 0)
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = call i32 @close(i32 %21)
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
ret void
}

LLVM IR (-O2):
define void @sheep(i32 %0) {
%2 = alloca [10 x i32]
%3 = bitcast [10 x i32]* %2 to i8*
%4 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 0
store i32 1, i32* %4
%5 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 1
store i32 %0, i32* %5
%6 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 2
%7 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 0, i32 0, i32 0, i32 768>, <4 x i32>* %7
%8 = getelementptr inbounds [10 x i32], [10 x i32]* %2, i64 0, i64 6
%9 = bitcast i32* %8 to i8*
%10 = call i32 @syscall(i32 298, i32* %4, i32 0, i32 -1, i32 -1, i32 0)
%11 = call i32 @close(i32 %10)
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
ret void
}