#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 */
char *getenv(char *);
scalar_t__ strcmp(char *, char *);
char *strtok(char *, char *);
const char *default_theme_for_terminal() {
  char *color_fg_bg = getenv("COLORFGBG");
  if (color_fg_bg) {
    strtok(color_fg_bg, ";");
    char *bg = strtok(NULL, ";");
    if (bg && strcmp(bg, "0") == 0) {
      return "dark";
    }
  }
  return "light";
}


x86 assembly (clang, -O0):
<default_theme_for_terminal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11b1 <default_theme_for_terminal+0x81>
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
call   1050 <strtok@plt>
xor    %eax,%eax
mov    %eax,%edi
lea    0xe9c(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ac <default_theme_for_terminal+0x7c>
mov    -0x18(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ac <default_theme_for_terminal+0x7c>
lea    0xe6b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11bc <default_theme_for_terminal+0x8c>
jmp    11b1 <default_theme_for_terminal+0x81>
lea    0xe5b(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<default_theme_for_terminal>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
call   1030 <getenv@plt>
lea    0xecc(%rip),%rbx
test   %rax,%rax
je     1188 <default_theme_for_terminal+0x58>
lea    0xeb7(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <strtok@plt>
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <strtok@plt>
test   %rax,%rax
je     1188 <default_theme_for_terminal+0x58>
lea    0xe98(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1188 <default_theme_for_terminal+0x58>
lea    0xe86(%rip),%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"COLORFGBG\00"
@.str.1 = [2 x i8] c";\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [5 x i8] c"dark\00"
@.str.4 = [6 x i8] c"light\00"
define i8* @default_theme_for_terminal() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %2
%5 = load i8*, i8** %2
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %19
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call i8* @strtok(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %18
13: ; preds = %7
%14 = load i8*, i8** %3
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %20
18: ; preds = %13, %7
br label %19
19: ; preds = %18, %0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %20
20: ; preds = %19, %17
%21 = load i8*, i8** %1
ret i8* %21
}

LLVM IR (-O2):
@.str = [10 x i8] c"COLORFGBG\00"
@.str.1 = [2 x i8] c";\00"
@.str.2 = [2 x i8] c"0\00"
@.str.3 = [5 x i8] c"dark\00"
@.str.4 = [6 x i8] c"light\00"
define i8* @default_theme_for_terminal() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %11, label %3
3: ; preds = %0
%4 = tail call i8* @strtok(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = tail call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %3, %7
br label %11
11: ; preds = %0, %10, %7
%12 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %10 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), %0 ]
ret i8* %12
}