#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 */
struct termios {
  char *c_cc;
};

/* Variables and functions */
int /*<<< orphan*/ TIOCSTI;
size_t VSUSP;
int /*<<< orphan*/ ioctl(int /*<<< orphan*/, int /*<<< orphan*/, char *);
int tcgetattr(int /*<<< orphan*/, struct termios *);
void send_suspend_signal(void) {
  struct termios g_dat;
  char cp[2];
  if (tcgetattr(0, &g_dat) == -1)
    return;
  cp[0] = g_dat.c_cc[VSUSP];
  cp[1] = 0;
  ioctl(0, TIOCSTI, cp);
}


x86 assembly (clang, -O0):
<send_suspend_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %edi,%edi
lea    -0x8(%rbp),%rsi
call   1040 <tcgetattr@plt>
cmp    $0xffffffff,%eax
jne    1141 <send_suspend_signal+0x21>
jmp    116d <send_suspend_signal+0x4d>
mov    -0x8(%rbp),%rax
mov    0x2e84(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xa(%rbp)
movb   $0x0,-0x9(%rbp)
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
lea    -0xa(%rbp),%rdx
xor    %edi,%edi
call   1030 <ioctl@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_suspend_signal>:
sub    $0x18,%rsp
lea    0x10(%rsp),%rsi
xor    %edi,%edi
call   1040 <tcgetattr@plt>
cmp    $0xffffffff,%eax
je     1165 <send_suspend_signal+0x45>
mov    0x10(%rsp),%rax
mov    0x2e8f(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
lea    0xe(%rsp),%rdx
xor    %edi,%edi
call   1030 <ioctl@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.termios = type { i8* }
@VSUSP = global i64 0
@TIOCSTI = global i32 0
define void @send_suspend_signal() {
%1 = alloca %struct.termios
%2 = alloca [2 x i8]
%3 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %6
5: ; preds = %0
br label %17
6: ; preds = %0
%7 = getelementptr inbounds %struct.termios, %struct.termios* %1, i32 0, i32 0
%8 = load i8*, i8** %7
%9 = load i64, i64* @VSUSP
%10 = getelementptr inbounds i8, i8* %8, i64 %9
%11 = load i8, i8* %10
%12 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
store i8 %11, i8* %12
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 0, i8* %13
%14 = load i32, i32* @TIOCSTI
%15 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%16 = call i32 @ioctl(i32 0, i32 %14, i8* %15)
br label %17
17: ; preds = %6, %5
ret void
}

LLVM IR (-O2):
%struct.termios = type { i8* }
@VSUSP = global i64 0
@TIOCSTI = global i32 0
define void @send_suspend_signal() {
%1 = alloca %struct.termios
%2 = alloca [2 x i8]
%3 = bitcast %struct.termios* %1 to i8*
%4 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 0
%5 = call i32 @tcgetattr(i32 0, %struct.termios* %1)
%6 = icmp eq i32 %5, -1
br i1 %6, label %16, label %7
7: ; preds = %0
%8 = getelementptr inbounds %struct.termios, %struct.termios* %1, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = load i64, i64* @VSUSP
%11 = getelementptr inbounds i8, i8* %9, i64 %10
%12 = load i8, i8* %11
store i8 %12, i8* %4
%13 = getelementptr inbounds [2 x i8], [2 x i8]* %2, i64 0, i64 1
store i8 0, i8* %13
%14 = load i32, i32* @TIOCSTI
%15 = call i32 @ioctl(i32 0, i32 %14, i8* %4)
br label %16
16: ; preds = %0, %7
ret void
}