#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 /*<<< orphan*/ cb_cpp();
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*/ writeWorkspace();
int cb_generate() {
  int i;
  puts("Generating Code::Blocks workspace and project files:");
  if (!writeWorkspace())
    return 0;
  for (i = 0; i < prj_get_numpackages(); ++i) {
    prj_select_package(i);
    printf("...%s\n", prj_get_pkgname());
    if (prj_is_lang("c++") || prj_is_lang("c")) {
      if (!cb_cpp())
        return 0;
    } else {
      printf("** Error: unsupported language '%s'\n", prj_get_language());
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<cb_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe61(%rip),%rdi
call   1050 <puts@plt>
mov    $0x0,%al
call   1030 <writeWorkspace@plt>
cmp    $0x0,%eax
jne    11c0 <cb_generate+0x30>
movl   $0x0,-0x4(%rbp)
jmp    1288 <cb_generate+0xf8>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1080 <prj_get_numpackages@plt>
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
cmp    %ecx,%eax
jge    1281 <cb_generate+0xf1>
mov    -0x8(%rbp),%edi
call   10b0 <prj_select_package@plt>
mov    $0x0,%al
call   10a0 <prj_get_pkgname@plt>
mov    %rax,%rsi
lea    0xe3b(%rip),%rdi
call   1070 <printf@plt>
lea    0xe36(%rip),%rdi
call   1040 <prj_is_lang@plt>
cmp    $0x0,%rax
jne    122b <cb_generate+0x9b>
lea    0xe24(%rip),%rdi
call   1040 <prj_is_lang@plt>
cmp    $0x0,%rax
je     124c <cb_generate+0xbc>
mov    $0x0,%al
call   1090 <cb_cpp@plt>
cmp    $0x0,%eax
jne    1247 <cb_generate+0xb7>
movl   $0x0,-0x4(%rbp)
jmp    1288 <cb_generate+0xf8>
jmp    126e <cb_generate+0xde>
mov    $0x0,%al
call   1060 <prj_get_language@plt>
mov    %rax,%rsi
lea    0xde5(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1288 <cb_generate+0xf8>
jmp    1273 <cb_generate+0xe3>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11c7 <cb_generate+0x37>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cb_generate>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xe61(%rip),%rdi
call   1050 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <writeWorkspace@plt>
test   %eax,%eax
je     1231 <cb_generate+0xa1>
xor    %eax,%eax
call   1080 <prj_get_numpackages@plt>
test   %eax,%eax
jle    122c <cb_generate+0x9c>
lea    0xe6e(%rip),%r14
lea    0xe6e(%rip),%r12
lea    0xe6b(%rip),%r15
xor    %ebp,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebp,%edi
call   10b0 <prj_select_package@plt>
xor    %eax,%eax
call   10a0 <prj_get_pkgname@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
mov    %r12,%rdi
call   1040 <prj_is_lang@plt>
test   %rax,%rax
jne    1213 <cb_generate+0x83>
mov    %r15,%rdi
call   1040 <prj_is_lang@plt>
test   %rax,%rax
je     123c <cb_generate+0xac>
xor    %eax,%eax
call   1090 <cb_cpp@plt>
test   %eax,%eax
je     1231 <cb_generate+0xa1>
add    $0x1,%ebp
xor    %eax,%eax
call   1080 <prj_get_numpackages@plt>
cmp    %eax,%ebp
jl     11e0 <cb_generate+0x50>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <prj_get_language@plt>
lea    0xdf6(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
jmp    1231 <cb_generate+0xa1>

LLVM IR (-O0):
@.str = [53 x i8] c"Generating Code::Blocks workspace and project files:\00"
@.str.1 = [7 x i8] c"...%s\0A\00"
@.str.2 = [4 x i8] c"c++\00"
@.str.3 = [2 x i8] c"c\00"
@.str.4 = [37 x i8] c"** Error: unsupported language '%s'\0A\00"
define i32 @cb_generate() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 @puts(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (...) @writeWorkspace()
%5 = icmp ne i32 %4, 0
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 0, i32* %1
br label %35
7: ; preds = %0
store i32 0, i32* %2
br label %8
8: ; preds = %31, %7
%9 = load i32, i32* %2
%10 = call i32 (...) @prj_get_numpackages()
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %34
12: ; preds = %8
%13 = load i32, i32* %2
%14 = call i32 @prj_select_package(i32 %13)
%15 = call i8* (...) @prj_get_pkgname()
%16 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i64 @prj_is_lang(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp ne i64 %17, 0
br i1 %18, label %22, label %19
19: ; preds = %12
%20 = call i64 @prj_is_lang(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19, %12
%23 = call i32 (...) @cb_cpp()
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %22
store i32 0, i32* %1
br label %35
26: ; preds = %22
br label %30
27: ; preds = %19
%28 = call i8* (...) @prj_get_language()
%29 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %28)
store i32 0, i32* %1
br label %35
30: ; preds = %26
br label %31
31: ; preds = %30
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
store i32 %33, i32* %2
br label %8
34: ; preds = %8
store i32 1, i32* %1
br label %35
35: ; preds = %34, %27, %25, %6
%36 = load i32, i32* %1
ret i32 %36
}

LLVM IR (-O2):
@.str = [53 x i8] c"Generating Code::Blocks workspace and project files:\00"
@.str.1 = [7 x i8] c"...%s\0A\00"
@.str.2 = [4 x i8] c"c++\00"
@.str.3 = [2 x i8] c"c\00"
@.str.4 = [37 x i8] c"** Error: unsupported language '%s'\0A\00"
define i32 @cb_generate() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @writeWorkspace()
%3 = icmp eq i32 %2, 0
br i1 %3, label %27, label %4
4: ; preds = %0
%5 = tail call i32 (...) @prj_get_numpackages()
%6 = icmp sgt i32 %5, 0
br i1 %6, label %10, label %27
7: ; preds = %20
%8 = tail call i32 (...) @prj_get_numpackages()
%9 = icmp slt i32 %23, %8
br i1 %9, label %10, label %27
10: ; preds = %4, %7
%11 = phi i32 [ %23, %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 ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %10
%18 = tail call i64 @prj_is_lang(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %24, label %20
20: ; preds = %17, %10
%21 = tail call i32 (...) @cb_cpp()
%22 = icmp eq i32 %21, 0
%23 = add nuw nsw i32 %11, 1
br i1 %22, label %27, label %7
24: ; preds = %17
%25 = tail call i8* (...) @prj_get_language()
%26 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %20, %7, %4, %0, %24
%28 = phi i32 [ 0, %24 ], [ 0, %0 ], [ 1, %4 ], [ 0, %20 ], [ 1, %7 ]
ret i32 %28
}