#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 */
size_t read_string();
size_t strlen(char *);
scalar_t__ write_tty(char *, size_t);
int send_command(char *cmd, int chk) {
  do {
  } while (0);
  size_t L = strlen(cmd);
  if (write_tty(cmd, L)) {
    do {
    } while (0);
    return 0;
  }
  if (chk) {
    size_t L = read_string();
    if (L == 0) {
      do {
      } while (0);
      return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<send_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
jmp    1144 <send_command+0x14>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <write_tty@plt>
cmp    $0x0,%rax
je     117e <send_command+0x4e>
jmp    116d <send_command+0x3d>
jmp    1172 <send_command+0x42>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <send_command+0x90>
cmpl   $0x0,-0x14(%rbp)
je     11b9 <send_command+0x89>
mov    $0x0,%al
call   1050 <read_string@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11b4 <send_command+0x84>
jmp    11a3 <send_command+0x73>
jmp    11a8 <send_command+0x78>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <send_command+0x90>
jmp    11b9 <send_command+0x89>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_command>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rbp
call   1030 <strlen@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1040 <write_tty@plt>
xor    %ebp,%ebp
test   %rax,%rax
jne    1166 <send_command+0x36>
test   %ebx,%ebx
je     1161 <send_command+0x31>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <read_string@plt>
test   %rax,%rax
je     1166 <send_command+0x36>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @send_command(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %4
store i32 %1, i32* %5
br label %8
8: ; preds = %2
br label %9
9: ; preds = %8
%10 = load i8*, i8** %4
%11 = call i64 @strlen(i8* %10)
store i64 %11, i64* %6
%12 = load i8*, i8** %4
%13 = load i64, i64* %6
%14 = call i64 @write_tty(i8* %12, i64 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
br label %17
17: ; preds = %16
br label %18
18: ; preds = %17
store i32 0, i32* %3
br label %31
19: ; preds = %9
%20 = load i32, i32* %5
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = call i64 (...) @read_string()
store i64 %23, i64* %7
%24 = load i64, i64* %7
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %22
br label %27
27: ; preds = %26
br label %28
28: ; preds = %27
store i32 0, i32* %3
br label %31
29: ; preds = %22
br label %30
30: ; preds = %29, %19
store i32 1, i32* %3
br label %31
31: ; preds = %30, %28, %18
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @send_command(i8* %0, i32 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = tail call i64 @write_tty(i8* %0, i64 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = icmp eq i32 %1, 0
br i1 %7, label %11, label %8
8: ; preds = %6
%9 = tail call i64 (...) @read_string()
%10 = icmp eq i64 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %8, %6
br label %12
12: ; preds = %2, %8, %11
%13 = phi i32 [ 1, %11 ], [ 0, %8 ], [ 0, %2 ]
ret i32 %13
}