#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*/ FILE;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fix_description(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
void generate_control_file(int argc, char *argv[]) {
  FILE *fp;
  char fn[1024] = {0};
  char line[1024] = {0};
  sprintf(fn, "%s/control", argv[1]);
  fp = fopen(fn, "wb");
  if (!fp) {
    printf("file open error\n");
    exit(-2);
  }
  sprintf(line, "Package: %s\n", argv[2]);
  fputs(line, fp);
  sprintf(line, "Version: %s\n", argv[3]);
  fputs(line, fp);
  sprintf(line, "Section: %s\n", argv[4]);
  fputs(line, fp);
  sprintf(line, "Priority: optional\n");
  fputs(line, fp);
  sprintf(line, "Architecture: %s\n", argv[6]);
  fputs(line, fp);
  sprintf(line, "Depends: %s\n", argv[7]);
  fputs(line, fp);
  sprintf(line, "Installed-Size: %d\n", atoi(argv[8]));
  fputs(line, fp);
  sprintf(line, "Maintainer: %s\n", argv[9]);
  fputs(line, fp);
  sprintf(line, "Description: %s\n%s\n", argv[10], argv[11]);
  fix_description(line);
  fputs(line, fp);
  fclose(fp);
}


x86 assembly (clang, -O0):
<generate_control_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x830,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x420(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x420(%rbp),%rdi
lea    0xe18(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    121d <generate_control_file+0x8d>
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
mov    $0xfffffffe,%edi
call   10b0 <exit@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdx
lea    0xdcc(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdx
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
lea    -0x820(%rbp),%rdi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdx
lea    0xd7b(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdx
lea    0xd60(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
lea    -0x820(%rbp),%rax
mov    %rax,-0x828(%rbp)
mov    -0x10(%rbp),%rax
mov    0x40(%rax),%rdi
call   1090 <atoi@plt>
mov    -0x828(%rbp),%rdi
mov    %eax,%edx
lea    0xd2b(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x48(%rax),%rdx
lea    0xd12(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x50(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x58(%rax),%rcx
lea    0xced(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
lea    -0x820(%rbp),%rdi
call   1050 <fix_description@plt>
lea    -0x820(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <fputs@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x830,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_control_file>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
mov    %rsi,%r14
lea    0x400(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    %rsp,%rdi
mov    $0x400,%edx
xor    %esi,%esi
call   1070 <memset@plt>
mov    0x8(%r14),%rdx
lea    0xe30(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
lea    0xe2a(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     133e <generate_control_file+0x1ae>
mov    %rax,%rbx
mov    0x10(%r14),%rdx
lea    0xe0e(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x18(%r14),%rdx
lea    0xdf8(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x20(%r14),%rdx
lea    0xde5(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
movups 0xdd6(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0xa6c61,0x10(%rsp)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x30(%r14),%rdx
lea    0xdc8(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x38(%r14),%rdx
lea    0xdba(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x40(%r14),%rdi
call   1090 <atoi@plt>
lea    0xda2(%rip),%rsi
mov    %r15,%rdi
mov    %eax,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x48(%r14),%rdx
lea    0xd94(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    0x50(%r14),%rdx
mov    0x58(%r14),%rcx
lea    0xd80(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %r15,%rdi
call   1050 <fix_description@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1060 <fputs@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xd5b(%rip),%rdi
call   1030 <puts@plt>
mov    $0xfffffffe,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"%s/control\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.2 = [17 x i8] c"file open error\0A\00"
@.str.3 = [13 x i8] c"Package: %s\0A\00"
@.str.4 = [13 x i8] c"Version: %s\0A\00"
@.str.5 = [13 x i8] c"Section: %s\0A\00"
@.str.6 = [20 x i8] c"Priority: optional\0A\00"
@.str.7 = [18 x i8] c"Architecture: %s\0A\00"
@.str.8 = [13 x i8] c"Depends: %s\0A\00"
@.str.9 = [20 x i8] c"Installed-Size: %d\0A\00"
@.str.10 = [16 x i8] c"Maintainer: %s\0A\00"
@.str.11 = [20 x i8] c"Description: %s\0A%s\0A\00"
define void @generate_control_file(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32*
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
store i32 %0, i32* %3
store i8** %1, i8*** %4
%8 = bitcast [1024 x i8]* %6 to i8*
%9 = bitcast [1024 x i8]* %7 to i8*
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = load i8**, i8*** %4
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 (i8*, i8*, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%16 = call i32* @fopen(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %16, i32** %5
%17 = load i32*, i32** %5
%18 = icmp ne i32* %17, null
br i1 %18, label %22, label %19
19: ; preds = %2
%20 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @exit(i32 -2)
unreachable
22: ; preds = %2
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%24 = load i8**, i8*** %4
%25 = getelementptr inbounds i8*, i8** %24, i64 2
%26 = load i8*, i8** %25
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%29 = load i32*, i32** %5
%30 = call i32 @fputs(i8* %28, i32* %29)
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%32 = load i8**, i8*** %4
%33 = getelementptr inbounds i8*, i8** %32, i64 3
%34 = load i8*, i8** %33
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %34)
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%37 = load i32*, i32** %5
%38 = call i32 @fputs(i8* %36, i32* %37)
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 4
%42 = load i8*, i8** %41
%43 = call i32 (i8*, i8*, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %42)
%44 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%45 = load i32*, i32** %5
%46 = call i32 @fputs(i8* %44, i32* %45)
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%48 = call i32 (i8*, i8*, ...) @sprintf(i8* %47, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%50 = load i32*, i32** %5
%51 = call i32 @fputs(i8* %49, i32* %50)
%52 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%53 = load i8**, i8*** %4
%54 = getelementptr inbounds i8*, i8** %53, i64 6
%55 = load i8*, i8** %54
%56 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %55)
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%58 = load i32*, i32** %5
%59 = call i32 @fputs(i8* %57, i32* %58)
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%61 = load i8**, i8*** %4
%62 = getelementptr inbounds i8*, i8** %61, i64 7
%63 = load i8*, i8** %62
%64 = call i32 (i8*, i8*, ...) @sprintf(i8* %60, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %63)
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%66 = load i32*, i32** %5
%67 = call i32 @fputs(i8* %65, i32* %66)
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%69 = load i8**, i8*** %4
%70 = getelementptr inbounds i8*, i8** %69, i64 8
%71 = load i8*, i8** %70
%72 = call i32 @atoi(i8* %71)
%73 = call i32 (i8*, i8*, ...) @sprintf(i8* %68, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %72)
%74 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%75 = load i32*, i32** %5
%76 = call i32 @fputs(i8* %74, i32* %75)
%77 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%78 = load i8**, i8*** %4
%79 = getelementptr inbounds i8*, i8** %78, i64 9
%80 = load i8*, i8** %79
%81 = call i32 (i8*, i8*, ...) @sprintf(i8* %77, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %80)
%82 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%83 = load i32*, i32** %5
%84 = call i32 @fputs(i8* %82, i32* %83)
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%86 = load i8**, i8*** %4
%87 = getelementptr inbounds i8*, i8** %86, i64 10
%88 = load i8*, i8** %87
%89 = load i8**, i8*** %4
%90 = getelementptr inbounds i8*, i8** %89, i64 11
%91 = load i8*, i8** %90
%92 = call i32 (i8*, i8*, ...) @sprintf(i8* %85, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %88, i8* %91)
%93 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%94 = call i32 @fix_description(i8* %93)
%95 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%96 = load i32*, i32** %5
%97 = call i32 @fputs(i8* %95, i32* %96)
%98 = load i32*, i32** %5
%99 = call i32 @fclose(i32* %98)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s/control\00"
@.str.1 = [3 x i8] c"wb\00"
@.str.3 = [13 x i8] c"Package: %s\0A\00"
@.str.4 = [13 x i8] c"Version: %s\0A\00"
@.str.5 = [13 x i8] c"Section: %s\0A\00"
@.str.6 = [20 x i8] c"Priority: optional\0A\00"
@.str.7 = [18 x i8] c"Architecture: %s\0A\00"
@.str.8 = [13 x i8] c"Depends: %s\0A\00"
@.str.9 = [20 x i8] c"Installed-Size: %d\0A\00"
@.str.10 = [16 x i8] c"Maintainer: %s\0A\00"
@.str.11 = [20 x i8] c"Description: %s\0A%s\0A\00"
@str = [16 x i8] c"file open error\00"
define void @generate_control_file(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 (i8*, i8*, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @exit(i32 -2)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 2
%17 = load i8*, i8** %16
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8* %17)
%19 = call i32 @fputs(i8* %6, i32* %10)
%20 = getelementptr inbounds i8*, i8** %1, i64 3
%21 = load i8*, i8** %20
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i8* %21)
%23 = call i32 @fputs(i8* %6, i32* %10)
%24 = getelementptr inbounds i8*, i8** %1, i64 4
%25 = load i8*, i8** %24
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = call i32 @fputs(i8* %6, i32* %10)
%28 = call i32 @fputs(i8* %6, i32* %10)
%29 = getelementptr inbounds i8*, i8** %1, i64 6
%30 = load i8*, i8** %29
%31 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.7, i64 0, i64 0), i8* %30)
%32 = call i32 @fputs(i8* %6, i32* %10)
%33 = getelementptr inbounds i8*, i8** %1, i64 7
%34 = load i8*, i8** %33
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* %34)
%36 = call i32 @fputs(i8* %6, i32* %10)
%37 = getelementptr inbounds i8*, i8** %1, i64 8
%38 = load i8*, i8** %37
%39 = tail call i32 @atoi(i8* %38)
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i32 %39)
%41 = call i32 @fputs(i8* %6, i32* %10)
%42 = getelementptr inbounds i8*, i8** %1, i64 9
%43 = load i8*, i8** %42
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i8* %43)
%45 = call i32 @fputs(i8* %6, i32* %10)
%46 = getelementptr inbounds i8*, i8** %1, i64 10
%47 = load i8*, i8** %46
%48 = getelementptr inbounds i8*, i8** %1, i64 11
%49 = load i8*, i8** %48
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.11, i64 0, i64 0), i8* %47, i8* %49)
%51 = call i32 @fix_description(i8* %6)
%52 = call i32 @fputs(i8* %6, i32* %10)
%53 = call i32 @fclose(i32* %10)
ret void
}