#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 *setup_stack(char *buf, size_t argc) {
  if (argc <= 6) {
    return buf;
  } else {
    buf[0] = 0x55;
    buf[1] = 0x48;
    buf[2] = 0x89;
    buf[3] = 0xe5;
    buf[4] = 0x48;
    buf[5] = 0x83;
    buf[6] = 0xec;
    buf[7] = (unsigned char)((argc - 6) * 8);
    return buf + 8;
  }
}


x86 assembly (clang, -O0):
<setup_stack>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x6,-0x18(%rbp)
ja     1124 <setup_stack+0x24>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117c <setup_stack+0x7c>
mov    -0x10(%rbp),%rax
movb   $0x55,(%rax)
mov    -0x10(%rbp),%rax
movb   $0x48,0x1(%rax)
mov    -0x10(%rbp),%rax
movb   $0x89,0x2(%rax)
mov    -0x10(%rbp),%rax
movb   $0xe5,0x3(%rax)
mov    -0x10(%rbp),%rax
movb   $0x48,0x4(%rax)
mov    -0x10(%rbp),%rax
movb   $0x83,0x5(%rax)
mov    -0x10(%rbp),%rax
movb   $0xec,0x6(%rax)
mov    -0x18(%rbp),%rax
sub    $0x6,%rax
shl    $0x3,%rax
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x7(%rax)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<setup_stack>:
mov    %rdi,%rax
cmp    $0x7,%rsi
jb     1129 <setup_stack+0x29>
movl   $0xe5894855,(%rax)
movw   $0x8348,0x4(%rax)
movb   $0xec,0x6(%rax)
shl    $0x3,%sil
add    $0xd0,%sil
mov    %sil,0x7(%rax)
add    $0x8,%rax
ret

LLVM IR (-O0):
define i8* @setup_stack(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%6 = load i64, i64* %5
%7 = icmp ule i64 %6, 6
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = load i8*, i8** %4
store i8* %9, i8** %3
br label %33
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8 85, i8* %12
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8 72, i8* %14
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 2
store i8 -119, i8* %16
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 3
store i8 -27, i8* %18
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 4
store i8 72, i8* %20
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i64 5
store i8 -125, i8* %22
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 6
store i8 -20, i8* %24
%25 = load i64, i64* %5
%26 = sub i64 %25, 6
%27 = mul i64 %26, 8
%28 = trunc i64 %27 to i8
%29 = load i8*, i8** %4
%30 = getelementptr inbounds i8, i8* %29, i64 7
store i8 %28, i8* %30
%31 = load i8*, i8** %4
%32 = getelementptr inbounds i8, i8* %31, i64 8
store i8* %32, i8** %3
br label %33
33: ; preds = %10, %8
%34 = load i8*, i8** %3
ret i8* %34
}

LLVM IR (-O2):
define i8* @setup_stack(i8* writeonly %0, i64 %1) {
%3 = icmp ult i64 %1, 7
br i1 %3, label %16, label %4
4: ; preds = %2
store i8 85, i8* %0
%5 = getelementptr inbounds i8, i8* %0, i64 1
store i8 72, i8* %5
%6 = getelementptr inbounds i8, i8* %0, i64 2
store i8 -119, i8* %6
%7 = getelementptr inbounds i8, i8* %0, i64 3
store i8 -27, i8* %7
%8 = getelementptr inbounds i8, i8* %0, i64 4
store i8 72, i8* %8
%9 = getelementptr inbounds i8, i8* %0, i64 5
store i8 -125, i8* %9
%10 = getelementptr inbounds i8, i8* %0, i64 6
store i8 -20, i8* %10
%11 = trunc i64 %1 to i8
%12 = shl i8 %11, 3
%13 = add i8 %12, -48
%14 = getelementptr inbounds i8, i8* %0, i64 7
store i8 %13, i8* %14
%15 = getelementptr inbounds i8, i8* %0, i64 8
br label %16
16: ; preds = %2, %4
%17 = phi i8* [ %15, %4 ], [ %0, %2 ]
ret i8* %17
}