#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int check_ssd(char *node) {
  FILE *p = NULL;
  char buffer[256];
  int i, ret;
  ret = 0;
  if (strlen(node) > 256 - strlen("check-ssd ") - 10)
    goto out;
  sprintf(buffer,
          "check-ssd "
          "%s",
          node);
  p = popen(buffer, "r");
  if (!p) {
    printf("Failed to execute: %s\n", buffer);
    goto out;
  }
  ret = pclose(p);
out:
  return ret;
}


x86 assembly (clang, -O0):
<check_ssd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x11c(%rbp)
lea    0xe79(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%edx
mov    -0x11c(%rbp),%eax
mov    $0x100,%ecx
sub    %edx,%ecx
sub    $0xa,%ecx
cmp    %ecx,%eax
jle    11ab <check_ssd+0x5b>
jmp    120b <check_ssd+0xbb>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe4e(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1060 <popen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11fc <check_ssd+0xac>
lea    -0x110(%rbp),%rsi
lea    0xe28(%rip),%rdi
call   1040 <printf@plt>
jmp    120b <check_ssd+0xbb>
mov    -0x10(%rbp),%rdi
call   1050 <pclose@plt>
mov    %eax,-0x118(%rbp)
mov    -0x118(%rbp),%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_ssd>:
push   %rbp
push   %rbx
sub    $0x108,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xe96(%rip),%rdi
call   1030 <strlen@plt>
mov    $0xf6,%ecx
sub    %eax,%ecx
cmp    %ecx,%ebp
jg     11c3 <check_ssd+0x73>
lea    0xe8a(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
call   1070 <sprintf@plt>
lea    0xe82(%rip),%rsi
mov    %rbp,%rdi
call   1060 <popen@plt>
test   %rax,%rax
je     11b4 <check_ssd+0x64>
mov    %rax,%rdi
add    $0x108,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <pclose@plt>
lea    0xe5f(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"check-ssd \00"
@.str.1 = [13 x i8] c"check-ssd %s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [23 x i8] c"Failed to execute: %s\0A\00"
define i32 @check_ssd(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca [256 x i8]
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %2
store i32* null, i32** %3
store i32 0, i32* %6
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
%9 = call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%10 = sub nsw i32 256, %9
%11 = sub nsw i32 %10, 10
%12 = icmp sgt i32 %8, %11
br i1 %12, label %13, label %14
13: ; preds = %1
br label %28
14: ; preds = %1
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%16 = load i8*, i8** %2
%17 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%19 = call i32* @popen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %19, i32** %3
%20 = load i32*, i32** %3
%21 = icmp ne i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %14
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %23)
br label %28
25: ; preds = %14
%26 = load i32*, i32** %3
%27 = call i32 @pclose(i32* %26)
store i32 %27, i32* %6
br label %28
28: ; preds = %25, %22, %13
%29 = load i32, i32* %6
ret i32 %29
}

LLVM IR (-O2):
@.str = [11 x i8] c"check-ssd \00"
@.str.1 = [13 x i8] c"check-ssd %s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [23 x i8] c"Failed to execute: %s\0A\00"
define i32 @check_ssd(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = tail call i32 @strlen(i8* %0)
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = sub i32 246, %5
%7 = icmp sgt i32 %4, %6
br i1 %7, label %16, label %8
8: ; preds = %1
%9 = call i32 @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%10 = call i32* @popen(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %14
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %3)
br label %16
14: ; preds = %8
%15 = tail call i32 @pclose(i32* %10)
br label %16
16: ; preds = %1, %14, %12
%17 = phi i32 [ 0, %1 ], [ %15, %14 ], [ 0, %12 ]
ret i32 %17
}