#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 /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
int strlen(char const *);
void lead(const char *rpmPath, const char *rpmName) {
  FILE *fptr = NULL;
  char buf[96] = {'\0'};
  int i;
  fptr = fopen(rpmPath, "ab");
  if (fptr == NULL)
    goto exit;
  buf[0] = 0xed;
  buf[1] = 0xab;
  buf[2] = 0xee;
  buf[3] = 0xdb;
  buf[4] = 0x03;
  buf[5] = 0x00;
  buf[6] = 0x00;
  buf[7] = 0x00;
  buf[8] = 0x00;
  buf[9] = 0x01;
  for (i = 0; i < 66 && i < strlen(rpmName); i++)
    buf[i + 9] = rpmName[i];
  buf[76] = 0x00;
  buf[77] = 0x01;
  buf[78] = 0x00;
  buf[79] = 0x05;
  fwrite(buf, sizeof(buf), 1, fptr);
  fflush(fptr);
exit:
  if (fptr) {
    fclose(fptr);
    fptr = NULL;
  }
}


x86 assembly (clang, -O0):
<lead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x60,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11af <lead+0x4f>
jmp    1292 <lead+0x132>
movb   $0xed,-0x80(%rbp)
movb   $0xab,-0x7f(%rbp)
movb   $0xee,-0x7e(%rbp)
movb   $0xdb,-0x7d(%rbp)
movb   $0x3,-0x7c(%rbp)
movb   $0x0,-0x7b(%rbp)
movb   $0x0,-0x7a(%rbp)
movb   $0x0,-0x79(%rbp)
movb   $0x0,-0x78(%rbp)
movb   $0x1,-0x77(%rbp)
movl   $0x0,-0x84(%rbp)
xor    %eax,%eax
cmpl   $0x42,-0x84(%rbp)
mov    %al,-0x85(%rbp)
jge    121e <lead+0xbe>
mov    -0x84(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cmp    %ecx,%eax
setl   %al
mov    %al,-0x85(%rbp)
mov    -0x85(%rbp),%al
test   $0x1,%al
jne    1231 <lead+0xd1>
jmp    1262 <lead+0x102>
mov    -0x10(%rbp),%rax
movslq -0x84(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x84(%rbp),%eax
add    $0x9,%eax
cltq
mov    %cl,-0x80(%rbp,%rax,1)
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11e1 <lead+0x81>
movb   $0x0,-0x34(%rbp)
movb   $0x1,-0x33(%rbp)
movb   $0x0,-0x32(%rbp)
movb   $0x5,-0x31(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x60,%esi
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fflush@plt>
cmpq   $0x0,-0x18(%rbp)
je     12ae <lead+0x14e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movq   $0x0,-0x18(%rbp)
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lead>:
push   %r15
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%r15
xorps  %xmm0,%xmm0
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe7d(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1208 <lead+0xb8>
mov    %rax,%r14
movl   $0xdbeeabed,(%rsp)
movb   $0x3,0x4(%rsp)
movl   $0x0,0x5(%rsp)
movb   $0x1,0x9(%rsp)
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    11d2 <lead+0x82>
movzbl (%r15,%rbx,1),%eax
mov    %al,0x9(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x42,%rbx
jne    11b0 <lead+0x60>
movl   $0x5000100,0x4c(%rsp)
05
mov    %rsp,%rdi
mov    $0x60,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1070 <fwrite@plt>
mov    %r14,%rdi
call   1050 <fflush@plt>
mov    %r14,%rdi
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <fclose@plt>
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ab\00"
define void @lead(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [96 x i8]
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32* null, i32** %5
%8 = bitcast [96 x i8]* %6 to i8*
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %5
%11 = load i32*, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %14
13: ; preds = %2
br label %58
14: ; preds = %2
%15 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 0
store i8 -19, i8* %15
%16 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 1
store i8 -85, i8* %16
%17 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 2
store i8 -18, i8* %17
%18 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 3
store i8 -37, i8* %18
%19 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 4
store i8 3, i8* %19
%20 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 5
store i8 0, i8* %20
%21 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 6
store i8 0, i8* %21
%22 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 7
store i8 0, i8* %22
%23 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 8
store i8 0, i8* %23
%24 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 9
store i8 1, i8* %24
store i32 0, i32* %7
br label %25
25: ; preds = %45, %14
%26 = load i32, i32* %7
%27 = icmp slt i32 %26, 66
br i1 %27, label %28, label %33
28: ; preds = %25
%29 = load i32, i32* %7
%30 = load i8*, i8** %4
%31 = call i32 @strlen(i8* %30)
%32 = icmp slt i32 %29, %31
br label %33
33: ; preds = %28, %25
%34 = phi i1 [ false, %25 ], [ %32, %28 ]
br i1 %34, label %35, label %48
35: ; preds = %33
%36 = load i8*, i8** %4
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 %43
store i8 %40, i8* %44
br label %45
45: ; preds = %35
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %25
48: ; preds = %33
%49 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 76
store i8 0, i8* %49
%50 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 77
store i8 1, i8* %50
%51 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 78
store i8 0, i8* %51
%52 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 79
store i8 5, i8* %52
%53 = getelementptr inbounds [96 x i8], [96 x i8]* %6, i64 0, i64 0
%54 = load i32*, i32** %5
%55 = call i32 @fwrite(i8* %53, i32 96, i32 1, i32* %54)
%56 = load i32*, i32** %5
%57 = call i32 @fflush(i32* %56)
br label %58
58: ; preds = %48, %13
%59 = load i32*, i32** %5
%60 = icmp ne i32* %59, null
br i1 %60, label %61, label %64
61: ; preds = %58
%62 = load i32*, i32** %5
%63 = call i32 @fclose(i32* %62)
store i32* null, i32** %5
br label %64
64: ; preds = %61, %58
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"ab\00"
define void @lead(i8* nocapture %0, i8* %1) {
%3 = alloca [96 x i8]
%4 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %35, label %7
7: ; preds = %2
store i8 -19, i8* %4
%8 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 1
store i8 -85, i8* %8
%9 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 2
store i8 -18, i8* %9
%10 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 3
store i8 -37, i8* %10
%11 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 4
store i8 3, i8* %11
%12 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 5
%13 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 9
%14 = bitcast i8* %12 to i32*
store i32 0, i32* %14
store i8 1, i8* %13
br label %15
15: ; preds = %7, %20
%16 = phi i64 [ 0, %7 ], [ %25, %20 ]
%17 = tail call i32 @strlen(i8* %1)
%18 = sext i32 %17 to i64
%19 = icmp slt i64 %16, %18
br i1 %19, label %20, label %27
20: ; preds = %15
%21 = getelementptr inbounds i8, i8* %1, i64 %16
%22 = load i8, i8* %21
%23 = add nuw nsw i64 %16, 9
%24 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 %23
store i8 %22, i8* %24
%25 = add nuw nsw i64 %16, 1
%26 = icmp eq i64 %25, 66
br i1 %26, label %27, label %15
27: ; preds = %20, %15
%28 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 76
store i8 0, i8* %28
%29 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 77
store i8 1, i8* %29
%30 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 78
store i8 0, i8* %30
%31 = getelementptr inbounds [96 x i8], [96 x i8]* %3, i64 0, i64 79
store i8 5, i8* %31
%32 = call i32 @fwrite(i8* %4, i32 96, i32 1, i32* %5)
%33 = tail call i32 @fflush(i32* %5)
%34 = tail call i32 @fclose(i32* %5)
br label %35
35: ; preds = %2, %27
ret void
}