#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char const *, char *);
int /*<<< orphan*/ strncat(char *, char const *, int);
int /*<<< orphan*/ system(char *);
int main(int argc, char const *argv[]) {
  int i;
  char buf[2048];
  if (argc < 2 || 0 != strcmp(argv[0], "color_compile")) {
    fprintf(stderr, "[color_compile] bad argument...\n");
    return 1;
  }
  if (3 == argc && 0 == strcmp(argv[1], "make") &&
      0 == strcmp(argv[2], "menuconfig")) {
    system("make menuconfig");
    return 0;
  }
  buf[0] = '\0';
  for (i = 1; i < argc; ++i) {
    strncat(buf, argv[i], 1024);
    strncat(buf, " ", 1024);
  }
  strncat(buf, "2>&1 | out_color_info", 1024);
  system(buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1184 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe8f(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11a5 <main+0x65>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1297 <main+0x157>
mov    $0x3,%eax
cmp    -0x8(%rbp),%eax
jne    120f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6d(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    120f <main+0xcf>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe55(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    120f <main+0xcf>
lea    0xe36(%rip),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
jmp    1297 <main+0x157>
movb   $0x0,-0x820(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    126c <main+0x12c>
lea    -0x820(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x400,%edx
call   1040 <strncat@plt>
lea    -0x820(%rbp),%rdi
lea    0xdf0(%rip),%rsi
mov    $0x400,%edx
call   1040 <strncat@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    121d <main+0xdd>
lea    -0x820(%rbp),%rdi
lea    0xdcc(%rip),%rsi
mov    $0x400,%edx
call   1040 <strncat@plt>
lea    -0x820(%rbp),%rdi
call   1030 <system@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x800,%rsp
cmp    $0x2,%edi
jl     116d <main+0x2d>
mov    %rsi,%r15
mov    %edi,%ebp
mov    (%rsi),%rdi
lea    0xe9d(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1197 <main+0x57>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x3,%ebp
jne    11c6 <main+0x86>
mov    0x8(%r15),%rdi
lea    0xe88(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11c6 <main+0x86>
mov    0x10(%r15),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     1230 <main+0xf0>
movb   $0x0,(%rsp)
mov    %ebp,%r12d
mov    $0x1,%ebx
mov    %rsp,%rbp
lea    0xe68(%rip),%r14
nopl   0x0(%rax)
mov    (%r15,%rbx,8),%rsi
mov    %rbp,%rdi
mov    $0x400,%edx
call   1040 <strncat@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x400,%edx
call   1040 <strncat@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11e0 <main+0xa0>
lea    0xe35(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%edx
call   1040 <strncat@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
xor    %eax,%eax
jmp    1187 <main+0x47>
lea    0xdfd(%rip),%rdi
jmp    1224 <main+0xe4>

LLVM IR (-O0):
@.str = [14 x i8] c"color_compile\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"[color_compile] bad argument...\0A\00"
@.str.2 = [5 x i8] c"make\00"
@.str.3 = [11 x i8] c"menuconfig\00"
@.str.4 = [16 x i8] c"make menuconfig\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [22 x i8] c"2>&1 | out_color_info\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [2048 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 0, %14
br i1 %15, label %16, label %19
16: ; preds = %10, %2
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %60
19: ; preds = %10
%20 = load i32, i32* %4
%21 = icmp eq i32 3, %20
br i1 %21, label %22, label %36
22: ; preds = %19
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%27 = icmp eq i64 0, %26
br i1 %27, label %28, label %36
28: ; preds = %22
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%33 = icmp eq i64 0, %32
br i1 %33, label %34, label %36
34: ; preds = %28
%35 = call i32 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %60
36: ; preds = %28, %22, %19
%37 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
store i8 0, i8* %37
store i32 1, i32* %6
br label %38
38: ; preds = %52, %36
%39 = load i32, i32* %6
%40 = load i32, i32* %4
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %55
42: ; preds = %38
%43 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%44 = load i8**, i8*** %5
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @strncat(i8* %43, i8* %48, i32 1024)
%50 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%51 = call i32 @strncat(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1024)
br label %52
52: ; preds = %42
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %38
55: ; preds = %38
%56 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%57 = call i32 @strncat(i8* %56, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 1024)
%58 = getelementptr inbounds [2048 x i8], [2048 x i8]* %7, i64 0, i64 0
%59 = call i32 @system(i8* %58)
store i32 0, i32* %3
br label %60
60: ; preds = %55, %34, %16
%61 = load i32, i32* %3
ret i32 %61
}

LLVM IR (-O2):
@.str = [14 x i8] c"color_compile\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"[color_compile] bad argument...\0A\00"
@.str.2 = [5 x i8] c"make\00"
@.str.3 = [11 x i8] c"menuconfig\00"
@.str.4 = [16 x i8] c"make menuconfig\00"
@.str.5 = [2 x i8] c" \00"
@.str.6 = [22 x i8] c"2>&1 | out_color_info\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %6, %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %40
13: ; preds = %6
%14 = icmp eq i32 %0, 3
br i1 %14, label %15, label %27
15: ; preds = %13
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %15
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = tail call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = tail call i32 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
br label %40
27: ; preds = %13, %15, %20
store i8 0, i8* %4
%28 = zext i32 %0 to i64
br label %29
29: ; preds = %27, %29
%30 = phi i64 [ 1, %27 ], [ %35, %29 ]
%31 = getelementptr inbounds i8*, i8** %1, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 @strncat(i8* %4, i8* %32, i32 1024)
%34 = call i32 @strncat(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i32 1024)
%35 = add nuw nsw i64 %30, 1
%36 = icmp eq i64 %35, %28
br i1 %36, label %37, label %29
37: ; preds = %29
%38 = call i32 @strncat(i8* %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 1024)
%39 = call i32 @system(i8* %4)
br label %40
40: ; preds = %37, %25, %10
%41 = phi i32 [ 1, %10 ], [ 0, %25 ], [ 0, %37 ]
ret i32 %41
}