#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*/ exit(int);
int /*<<< orphan*/ printf(char *, char *);
int run_proc(char **, char *, char *, char *, int /*<<< orphan*/);
char *strsep(char **, char *);
int main(int argc, char **argv) {
  char *gitbuff;
  int out = run_proc(&gitbuff, "git", "branch", "--list", 0);
  if (out != 0) {
    exit(1);
  }
  char *token;
  char *sep = " \r\n";
  int next = 0;
  while ((token = strsep(&gitbuff, sep)) != NULL) {
    if (token[0] == '*') {
      token = strsep(&gitbuff, sep);
      printf("(%s)", token);
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
lea    0xe9f(%rip),%rsi
lea    0xe9c(%rip),%rdx
lea    0xe9c(%rip),%rcx
xor    %r8d,%r8d
call   1040 <run_proc@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     118e <main+0x4e>
mov    $0x1,%edi
call   1060 <exit@plt>
lea    0xe7d(%rip),%rax
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x30(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1050 <strsep@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11f6 <main+0xb6>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2a,%eax
jne    11f1 <main+0xb1>
mov    -0x30(%rbp),%rsi
lea    -0x18(%rbp),%rdi
call   1050 <strsep@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
jmp    11f6 <main+0xb6>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rsi
lea    0xeb2(%rip),%rdx
lea    0xeb2(%rip),%rcx
mov    %rsp,%rdi
xor    %r8d,%r8d
call   1040 <run_proc@plt>
test   %eax,%eax
jne    11bd <main+0x7d>
lea    0xea3(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strsep@plt>
test   %rax,%rax
je     11b3 <main+0x73>
cmpb   $0x2a,(%rax)
jne    1180 <main+0x40>
lea    0xe76(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strsep@plt>
lea    0xe6b(%rip),%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"git\00"
@.str.1 = [7 x i8] c"branch\00"
@.str.2 = [7 x i8] c"--list\00"
@.str.3 = [4 x i8] c" \0D\0A\00"
@.str.4 = [5 x i8] c"(%s)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = call i32 @run_proc(i8** %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %9
store i32 0, i32* %10
br label %17
17: ; preds = %32, %16
%18 = load i8*, i8** %9
%19 = call i8* @strsep(i8** %6, i8* %18)
store i8* %19, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %33
21: ; preds = %17
%22 = load i8*, i8** %8
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 42
br i1 %26, label %27, label %32
27: ; preds = %21
%28 = load i8*, i8** %9
%29 = call i8* @strsep(i8** %6, i8* %28)
store i8* %29, i8** %8
%30 = load i8*, i8** %8
%31 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %30)
br label %33
32: ; preds = %21
br label %17
33: ; preds = %27, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"git\00"
@.str.1 = [7 x i8] c"branch\00"
@.str.2 = [7 x i8] c"--list\00"
@.str.3 = [4 x i8] c" \0D\0A\00"
@.str.4 = [5 x i8] c"(%s)\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 @run_proc(i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %2, %12
%10 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%11 = icmp eq i8* %10, null
br i1 %11, label %18, label %12
12: ; preds = %9
%13 = load i8, i8* %10
%14 = icmp eq i8 %13, 42
br i1 %14, label %15, label %9
15: ; preds = %12
%16 = call i8* @strsep(i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %9, %15
ret i32 0
}