#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 *, char *, char *, char *);
char *getenv(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strncmp(char *, char *, int);
void gui_window_set_bracketed_paste_mode(int enable) {
  char *envterm, *envtmux;
  int tmux, screen;
  envtmux = getenv("TMUX");
  tmux = (envtmux && envtmux[0]);
  envterm = getenv("TERM");
  screen = (envterm && (strncmp(envterm, "screen", 6) == 0) && !tmux);
  fprintf(stderr, "%s\033[?2004%s%s", (screen) ? "\033P" : "",
          (enable) ? "h" : "l", (screen) ? "\033\\" : "");
}


x86 assembly (clang, -O0):
<gui_window_set_bracketed_paste_mode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    0xebe(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x21(%rbp)
je     116b <gui_window_set_bracketed_paste_mode+0x3b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x1c(%rbp)
lea    0xe88(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x22(%rbp)
je     11c9 <gui_window_set_bracketed_paste_mode+0x99>
mov    -0x10(%rbp),%rdi
lea    0xe69(%rip),%rsi
mov    $0x6,%edx
call   1040 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x22(%rbp)
jne    11c9 <gui_window_set_bracketed_paste_mode+0x99>
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x20(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%ecx
lea    0xe22(%rip),%rdx
lea    0xe31(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
mov    -0x4(%rbp),%esi
lea    0xe25(%rip),%rcx
lea    0xe1c(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%rcx
mov    -0x20(%rbp),%esi
lea    0xdf2(%rip),%r8
lea    0xe08(%rip),%rax
cmp    $0x0,%esi
cmovne %rax,%r8
lea    0xde5(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_window_set_bracketed_paste_mode>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xec4(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     114e <gui_window_set_bracketed_paste_mode+0x1e>
cmpb   $0x0,(%rax)
sete   %bl
jmp    1150 <gui_window_set_bracketed_paste_mode+0x20>
mov    $0x1,%bl
lea    0xeae(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     119a <gui_window_set_bracketed_paste_mode+0x6a>
lea    0xea2(%rip),%rsi
mov    %rax,%rdi
mov    $0x6,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
sete   %al
and    %bl,%al
mov    0x2e5c(%rip),%rcx
mov    (%rcx),%edi
cmp    $0x1,%al
jne    11a3 <gui_window_set_bracketed_paste_mode+0x73>
lea    0xe95(%rip),%r8
lea    0xe87(%rip),%rdx
jmp    11ad <gui_window_set_bracketed_paste_mode+0x7d>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rdx
mov    %rdx,%r8
test   %ebp,%ebp
lea    0xe6e(%rip),%rax
lea    0xe65(%rip),%rcx
cmove  %rax,%rcx
lea    0xe49(%rip),%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <fprintf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"TMUX\00"
@.str.1 = [5 x i8] c"TERM\00"
@.str.2 = [7 x i8] c"screen\00"
@stderr = global i32 0
@.str.3 = [14 x i8] c"%s\1B[?2004%s%s\00"
@.str.4 = [3 x i8] c"\1BP\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [2 x i8] c"h\00"
@.str.7 = [2 x i8] c"l\00"
@.str.8 = [3 x i8] c"\1B\\\00"
define void @gui_window_set_bracketed_paste_mode(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
%7 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br label %16
16: ; preds = %10, %1
%17 = phi i1 [ false, %1 ], [ %15, %10 ]
%18 = zext i1 %17 to i32
store i32 %18, i32* %5
%19 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %19, i8** %3
%20 = load i8*, i8** %3
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %30
22: ; preds = %16
%23 = load i8*, i8** %3
%24 = call i64 @strncmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %5
%28 = icmp ne i32 %27, 0
%29 = xor i1 %28, true
br label %30
30: ; preds = %26, %22, %16
%31 = phi i1 [ false, %22 ], [ false, %16 ], [ %29, %26 ]
%32 = zext i1 %31 to i32
store i32 %32, i32* %6
%33 = load i32, i32* @stderr
%34 = load i32, i32* %6
%35 = icmp ne i32 %34, 0
%36 = zext i1 %35 to i64
%37 = select i1 %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0)
%38 = load i32, i32* %2
%39 = icmp ne i32 %38, 0
%40 = zext i1 %39 to i64
%41 = select i1 %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0)
%42 = load i32, i32* %6
%43 = icmp ne i32 %42, 0
%44 = zext i1 %43 to i64
%45 = select i1 %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0)
%46 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %37, i8* %41, i8* %45)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"TMUX\00"
@.str.1 = [5 x i8] c"TERM\00"
@.str.2 = [7 x i8] c"screen\00"
@stderr = global i32 0
@.str.3 = [14 x i8] c"%s\1B[?2004%s%s\00"
@.str.4 = [3 x i8] c"\1BP\00"
@.str.5 = [1 x i8] zeroinitializer
@.str.6 = [2 x i8] c"h\00"
@.str.7 = [2 x i8] c"l\00"
@.str.8 = [3 x i8] c"\1B\\\00"
define void @gui_window_set_bracketed_paste_mode(i32 %0) {
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br label %7
7: ; preds = %4, %1
%8 = phi i1 [ true, %1 ], [ %6, %4 ]
%9 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %7
%12 = load i32, i32* @stderr
br label %19
13: ; preds = %7
%14 = tail call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 6)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, i1 %8, i1 false
%17 = load i32, i32* @stderr
br i1 %16, label %18, label %19
18: ; preds = %13
br label %19
19: ; preds = %11, %13, %18
%20 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %18 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %11 ]
%21 = phi i32 [ %17, %18 ], [ %17, %13 ], [ %12, %11 ]
%22 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), %18 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.5, i64 0, i64 0), %11 ]
%23 = icmp eq i32 %0, 0
%24 = select i1 %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0)
%25 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %20, i8* %24, i8* %22)
ret void
}