#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 gnu_cpp();
int gnu_cs();
int /*<<< orphan*/ printf(char *, char *);
char *prj_get_language();
int prj_get_numpackages();
char *prj_get_pkgname();
scalar_t__ prj_is_lang(char *);
int /*<<< orphan*/ prj_select_package(int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ writeRootMakefile();
int gnu_generate() {
  int i;
  puts("Generating GNU makefiles:");
  if (!writeRootMakefile())
    return 0;
  for (i = 0; i < prj_get_numpackages(); ++i) {
    int result;
    prj_select_package(i);
    printf("...%s\n", prj_get_pkgname());
    if (prj_is_lang("c#")) {
      result = gnu_cs();
    } else if (prj_is_lang("c++") || prj_is_lang("c")) {
      result = gnu_cpp();
    } else {
      printf("** Error: unrecognized language '%s'\n", prj_get_language());
      return 0;
    }
    if (!result)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<gnu_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe51(%rip),%rdi
call   1050 <puts@plt>
mov    $0x0,%al
call   1080 <writeRootMakefile@plt>
cmp    $0x0,%eax
jne    11d0 <gnu_generate+0x30>
movl   $0x0,-0x4(%rbp)
jmp    12c6 <gnu_generate+0x126>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1090 <prj_get_numpackages@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
cmp    %ecx,%eax
jge    12bf <gnu_generate+0x11f>
mov    -0x8(%rbp),%edi
call   10c0 <prj_select_package@plt>
mov    $0x0,%al
call   10a0 <prj_get_pkgname@plt>
mov    %rax,%rsi
lea    0xe10(%rip),%rdi
call   1070 <printf@plt>
lea    0xe0b(%rip),%rdi
call   1030 <prj_is_lang@plt>
cmp    $0x0,%rax
je     1234 <gnu_generate+0x94>
mov    $0x0,%al
call   1040 <gnu_cs@plt>
mov    %eax,-0xc(%rbp)
jmp    1296 <gnu_generate+0xf6>
lea    0xde9(%rip),%rdi
call   1030 <prj_is_lang@plt>
cmp    $0x0,%rax
jne    1260 <gnu_generate+0xc0>
lea    0xdd7(%rip),%rdi
call   1030 <prj_is_lang@plt>
cmp    $0x0,%rax
je     126f <gnu_generate+0xcf>
mov    $0x0,%al
call   10b0 <gnu_cpp@plt>
mov    %eax,-0xc(%rbp)
jmp    1291 <gnu_generate+0xf1>
mov    $0x0,%al
call   1060 <prj_get_language@plt>
mov    %rax,%rsi
lea    0xdaa(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12c6 <gnu_generate+0x126>
jmp    1296 <gnu_generate+0xf6>
cmpl   $0x0,-0xc(%rbp)
jne    12ac <gnu_generate+0x10c>
movl   $0x0,-0x4(%rbp)
jmp    12c6 <gnu_generate+0x126>
jmp    12b1 <gnu_generate+0x111>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d7 <gnu_generate+0x37>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gnu_generate>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe4e(%rip),%rdi
call   1050 <puts@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1080 <writeRootMakefile@plt>
test   %eax,%eax
je     1278 <gnu_generate+0xd8>
xor    %eax,%eax
call   1090 <prj_get_numpackages@plt>
mov    $0x1,%r14d
test   %eax,%eax
jle    1278 <gnu_generate+0xd8>
lea    0xe35(%rip),%r13
lea    0xe35(%rip),%rbp
lea    0xe31(%rip),%r15
lea    0xe2e(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%edi
call   10c0 <prj_select_package@plt>
xor    %eax,%eax
call   10a0 <prj_get_pkgname@plt>
mov    %r13,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %rbp,%rdi
call   1030 <prj_is_lang@plt>
test   %rax,%rax
je     1240 <gnu_generate+0xa0>
xor    %eax,%eax
call   1040 <gnu_cs@plt>
test   %eax,%eax
jne    1265 <gnu_generate+0xc5>
jmp    1275 <gnu_generate+0xd5>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <prj_is_lang@plt>
test   %rax,%rax
jne    125a <gnu_generate+0xba>
mov    %r12,%rdi
call   1030 <prj_is_lang@plt>
test   %rax,%rax
je     128a <gnu_generate+0xea>
xor    %eax,%eax
call   10b0 <gnu_cpp@plt>
test   %eax,%eax
je     1275 <gnu_generate+0xd5>
add    $0x1,%ebx
xor    %eax,%eax
call   1090 <prj_get_numpackages@plt>
cmp    %eax,%ebx
jl     1200 <gnu_generate+0x60>
jmp    1278 <gnu_generate+0xd8>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <prj_get_language@plt>
lea    0xd8f(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
jmp    1278 <gnu_generate+0xd8>

LLVM IR (-O0):
@.str = [26 x i8] c"Generating GNU makefiles:\00"
@.str.1 = [7 x i8] c"...%s\0A\00"
@.str.2 = [3 x i8] c"c#\00"
@.str.3 = [4 x i8] c"c++\00"
@.str.4 = [2 x i8] c"c\00"
@.str.5 = [38 x i8] c"** Error: unrecognized language '%s'\0A\00"
define i32 @gnu_generate() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (...) @writeRootMakefile()
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %0
store i32 0, i32* %1
br label %43
8: ; preds = %0
store i32 0, i32* %2
br label %9
9: ; preds = %39, %8
%10 = load i32, i32* %2
%11 = call i32 (...) @prj_get_numpackages()
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %42
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 @prj_select_package(i32 %14)
%16 = call i8* (...) @prj_get_pkgname()
%17 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i64 @prj_is_lang(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 (...) @gnu_cs()
store i32 %21, i32* %3
br label %34
22: ; preds = %13
%23 = call i64 @prj_is_lang(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = call i64 @prj_is_lang(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %25, %22
%29 = call i32 (...) @gnu_cpp()
store i32 %29, i32* %3
br label %33
30: ; preds = %25
%31 = call i8* (...) @prj_get_language()
%32 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %31)
store i32 0, i32* %1
br label %43
33: ; preds = %28
br label %34
34: ; preds = %33, %20
%35 = load i32, i32* %3
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %34
store i32 0, i32* %1
br label %43
38: ; preds = %34
br label %39
39: ; preds = %38
%40 = load i32, i32* %2
%41 = add nsw i32 %40, 1
store i32 %41, i32* %2
br label %9
42: ; preds = %9
store i32 1, i32* %1
br label %43
43: ; preds = %42, %37, %30, %7
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [26 x i8] c"Generating GNU makefiles:\00"
@.str.1 = [7 x i8] c"...%s\0A\00"
@.str.2 = [3 x i8] c"c#\00"
@.str.3 = [4 x i8] c"c++\00"
@.str.4 = [2 x i8] c"c\00"
@.str.5 = [38 x i8] c"** Error: unrecognized language '%s'\0A\00"
define i32 @gnu_generate() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @writeRootMakefile()
%3 = icmp eq i32 %2, 0
br i1 %3, label %34, label %4
4: ; preds = %0
%5 = tail call i32 (...) @prj_get_numpackages()
%6 = icmp sgt i32 %5, 0
br i1 %6, label %10, label %34
7: ; preds = %30
%8 = tail call i32 (...) @prj_get_numpackages()
%9 = icmp slt i32 %33, %8
br i1 %9, label %10, label %34
10: ; preds = %4, %7
%11 = phi i32 [ %33, %7 ], [ 0, %4 ]
%12 = tail call i32 @prj_select_package(i32 %11)
%13 = tail call i8* (...) @prj_get_pkgname()
%14 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = tail call i64 @prj_is_lang(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %10
%18 = tail call i32 (...) @gnu_cs()
br label %30
19: ; preds = %10
%20 = tail call i64 @prj_is_lang(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = tail call i64 @prj_is_lang(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %22, %19
%26 = tail call i32 (...) @gnu_cpp()
br label %30
27: ; preds = %22
%28 = tail call i8* (...) @prj_get_language()
%29 = tail call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0), i8* %28)
br label %34
30: ; preds = %25, %17
%31 = phi i32 [ %18, %17 ], [ %26, %25 ]
%32 = icmp eq i32 %31, 0
%33 = add nuw nsw i32 %11, 1
br i1 %32, label %34, label %7
34: ; preds = %30, %7, %4, %27, %0
%35 = phi i32 [ 0, %0 ], [ 0, %27 ], [ 1, %4 ], [ 0, %30 ], [ 1, %7 ]
ret i32 %35
}