#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*/ ft_free(char *);
int /*<<< orphan*/ ft_putstr(char *);
scalar_t__ ft_strncmp(char *, char *, int);
char *result_cmd(char *);
int /*<<< orphan*/ write(int, char *, int);
void prompt_git(void) {
  char *result;
  int i;
  int v;
  i = 0;
  result = result_cmd("git branch");
  if (result) {
    if (ft_strncmp("fatal", result, 5)) {
      while (result[i] && result[i] != '*')
        ++i;
      v = i + 2;
      while (result[i] != '\n' && result[i])
        ++i;
      ft_putstr("\033[1;33m");
      ft_putstr("(");
      write(1, &result[v], (i - v));
      ft_putstr(")");
      ft_putstr("\033[0m");
    }
    ft_free(result);
  }
}


x86 assembly (clang, -O0):
<prompt_git>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
lea    0xe9a(%rip),%rdi
call   1050 <result_cmd@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1295 <prompt_git+0x145>
mov    -0x8(%rbp),%rsi
lea    0xe86(%rip),%rdi
mov    $0x5,%edx
call   1070 <ft_strncmp@plt>
cmp    $0x0,%rax
je     128c <prompt_git+0x13c>
jmp    119e <prompt_git+0x4e>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     11cd <prompt_git+0x7d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    11dd <prompt_git+0x8d>
jmp    11eb <prompt_git+0x9b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119e <prompt_git+0x4e>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x12(%rbp)
je     1223 <prompt_git+0xd3>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    1233 <prompt_git+0xe3>
jmp    1241 <prompt_git+0xf1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11f4 <prompt_git+0xa4>
lea    0xdc9(%rip),%rdi
call   1060 <ft_putstr@plt>
lea    0xdc5(%rip),%rdi
call   1060 <ft_putstr@plt>
mov    -0x8(%rbp),%rsi
movslq -0x10(%rbp),%rax
add    %rax,%rsi
mov    -0xc(%rbp),%edx
sub    -0x10(%rbp),%edx
mov    $0x1,%edi
call   1030 <write@plt>
lea    0xda0(%rip),%rdi
call   1060 <ft_putstr@plt>
lea    0xd96(%rip),%rdi
call   1060 <ft_putstr@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ft_free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prompt_git>:
push   %rbp
push   %r14
push   %rbx
lea    0xea5(%rip),%rdi
call   1050 <result_cmd@plt>
test   %rax,%rax
je     11a3 <prompt_git+0x53>
mov    %rax,%rbx
lea    0xe9c(%rip),%rdi
mov    %rax,%rsi
mov    $0x5,%edx
call   1070 <ft_strncmp@plt>
test   %rax,%rax
je     121a <prompt_git+0xca>
xor    %eax,%eax
nopw   0x0(%rax,%rax,1)
movzbl (%rbx,%rax,1),%ecx
test   %cl,%cl
je     11a8 <prompt_git+0x58>
cmp    $0x2a,%cl
je     11a8 <prompt_git+0x58>
add    $0x1,%rax
jmp    1190 <prompt_git+0x40>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0x2(%rax),%r14
mov    %eax,%eax
add    %rbx,%rax
mov    $0xfffffffe,%ebp
cs nopw 0x0(%rax,%rax,1)
movzbl (%rax),%ecx
test   %cl,%cl
je     11d5 <prompt_git+0x85>
cmp    $0xa,%cl
je     11d5 <prompt_git+0x85>
add    $0x1,%ebp
add    $0x1,%rax
jmp    11c0 <prompt_git+0x70>
lea    0xe35(%rip),%rdi
call   1060 <ft_putstr@plt>
lea    0xe31(%rip),%rdi
call   1060 <ft_putstr@plt>
mov    %r14d,%eax
mov    %rbx,%rsi
add    %rax,%rsi
mov    $0x1,%edi
mov    %ebp,%edx
call   1030 <write@plt>
lea    0xe12(%rip),%rdi
call   1060 <ft_putstr@plt>
lea    0xe08(%rip),%rdi
call   1060 <ft_putstr@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <ft_free@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"git branch\00"
@.str.1 = [6 x i8] c"fatal\00"
@.str.2 = [8 x i8] c"\1B[1;33m\00"
@.str.3 = [2 x i8] c"(\00"
@.str.4 = [2 x i8] c")\00"
@.str.5 = [5 x i8] c"\1B[0m\00"
define void @prompt_git() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %2
%4 = call i8* @result_cmd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %1
%5 = load i8*, i8** %1
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %73
7: ; preds = %0
%8 = load i8*, i8** %1
%9 = call i64 @ft_strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %8, i32 5)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %70
11: ; preds = %7
br label %12
12: ; preds = %30, %11
%13 = load i8*, i8** %1
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %28
20: ; preds = %12
%21 = load i8*, i8** %1
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 42
br label %28
28: ; preds = %20, %12
%29 = phi i1 [ false, %12 ], [ %27, %20 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %12
33: ; preds = %28
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 2
store i32 %35, i32* %3
br label %36
36: ; preds = %54, %33
%37 = load i8*, i8** %1
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 10
br i1 %43, label %44, label %52
44: ; preds = %36
%45 = load i8*, i8** %1
%46 = load i32, i32* %2
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %45, i64 %47
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %50, 0
br label %52
52: ; preds = %44, %36
%53 = phi i1 [ false, %36 ], [ %51, %44 ]
br i1 %53, label %54, label %57
54: ; preds = %52
%55 = load i32, i32* %2
%56 = add nsw i32 %55, 1
store i32 %56, i32* %2
br label %36
57: ; preds = %52
%58 = call i32 @ft_putstr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%59 = call i32 @ft_putstr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%60 = load i8*, i8** %1
%61 = load i32, i32* %3
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i32, i32* %2
%65 = load i32, i32* %3
%66 = sub nsw i32 %64, %65
%67 = call i32 @write(i32 1, i8* %63, i32 %66)
%68 = call i32 @ft_putstr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%69 = call i32 @ft_putstr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %70
70: ; preds = %57, %7
%71 = load i8*, i8** %1
%72 = call i32 @ft_free(i8* %71)
br label %73
73: ; preds = %70, %0
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"git branch\00"
@.str.1 = [6 x i8] c"fatal\00"
@.str.2 = [8 x i8] c"\1B[1;33m\00"
@.str.3 = [2 x i8] c"(\00"
@.str.4 = [2 x i8] c")\00"
@.str.5 = [5 x i8] c"\1B[0m\00"
define void @prompt_git() {
%1 = tail call i8* @result_cmd(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %34, label %3
3: ; preds = %0
%4 = tail call i64 @ft_strncmp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i32 5)
%5 = icmp eq i64 %4, 0
br i1 %5, label %32, label %6
6: ; preds = %3, %10
%7 = phi i64 [ %11, %10 ], [ 0, %3 ]
%8 = getelementptr inbounds i8, i8* %1, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %10 [
i8 0, label %12
i8 42, label %12
]
10: ; preds = %6
%11 = add nuw i64 %7, 1
br label %6
12: ; preds = %6, %6
%13 = trunc i64 %7 to i32
%14 = add nuw nsw i32 %13, 2
%15 = and i64 %7, 4294967295
br label %16
16: ; preds = %20, %12
%17 = phi i64 [ %21, %20 ], [ %15, %12 ]
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = load i8, i8* %18
switch i8 %19, label %20 [
i8 10, label %22
i8 0, label %22
]
20: ; preds = %16
%21 = add nuw i64 %17, 1
br label %16
22: ; preds = %16, %16
%23 = trunc i64 %17 to i32
%24 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = zext i32 %14 to i64
%27 = getelementptr inbounds i8, i8* %1, i64 %26
%28 = sub nsw i32 %23, %14
%29 = tail call i32 @write(i32 1, i8* %27, i32 %28)
%30 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%31 = tail call i32 @ft_putstr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %22, %3
%33 = tail call i32 @ft_free(i8* %1)
br label %34
34: ; preds = %32, %0
ret void
}