#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 *);
int sd_notify_supported(void) {
  const char *e;
  e = getenv("NOTIFY_SOCKET");
  if (!e)
    return 0;
  if ((e[0] != '@' && e[0] != '/') || e[1] == 0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<sd_notify_supported>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    113f <sd_notify_supported+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1183 <sd_notify_supported+0x73>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x40,%eax
je     115f <sd_notify_supported+0x4f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1170 <sd_notify_supported+0x60>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
jne    117c <sd_notify_supported+0x6c>
movl   $0x0,-0x4(%rbp)
jmp    1183 <sd_notify_supported+0x73>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sd_notify_supported>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     113c <sd_notify_supported+0x2c>
mov    (%rcx),%dl
cmp    $0x40,%dl
je     1133 <sd_notify_supported+0x23>
cmp    $0x2f,%dl
jne    113c <sd_notify_supported+0x2c>
xor    %eax,%eax
cmpb   $0x0,0x1(%rcx)
setne  %al
pop    %rcx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"NOTIFY_SOCKET\00"
define i32 @sd_notify_supported() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i8* @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %2
%4 = load i8*, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %0
store i32 0, i32* %1
br label %27
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 64
br i1 %12, label %13, label %19
13: ; preds = %7
%14 = load i8*, i8** %2
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 47
br i1 %18, label %25, label %19
19: ; preds = %13, %7
%20 = load i8*, i8** %2
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19, %13
store i32 0, i32* %1
br label %27
26: ; preds = %19
store i32 1, i32* %1
br label %27
27: ; preds = %26, %25, %6
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [14 x i8] c"NOTIFY_SOCKET\00"
define i32 @sd_notify_supported() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %10, label %3
3: ; preds = %0
%4 = load i8, i8* %1
switch i8 %4, label %10 [
i8 64, label %5
i8 47, label %5
]
5: ; preds = %3, %3
%6 = getelementptr inbounds i8, i8* %1, i64 1
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
%9 = zext i1 %8 to i32
br label %10
10: ; preds = %5, %3, %0
%11 = phi i32 [ 0, %0 ], [ 0, %3 ], [ %9, %5 ]
ret i32 %11
}