#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*/ printf(char *, ...);
int ttgmdm();
void shomdm() {
  int y;
  y = ttgmdm();
  switch (y) {
  case -3:
    printf("Modem signals unavailable in this version of Kermit\r\n");
    break;
  case -2:
    printf("No modem control for this device\r\n");
    break;
  case -1:
    printf("Modem signals unavailable\r\n");
    break;
  default:
    printf(" Carrier Detect      (CD):  %s\r\n", (y & 0004) ? "On" : "Off");
    printf(" Dataset Ready       (DSR): %s\r\n", (y & 0002) ? "On" : "Off");
    printf(" Clear To Send       (CTS): %s\r\n", (y & 0001) ? "On" : "Off");
    printf(" Ring Indicator      (RI):  %s\r\n", (y & 0010) ? "On" : "Off");
    printf(" Data Terminal Ready (DTR): %s\r\n", (y & 0020) ? "On" : "Off");
    printf(" Request To Send     (RTS): %s\r\n", (y & 0040) ? "On" : "Off");
  }
}


x86 assembly (clang, -O0):
<shomdm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
call   1040 <ttgmdm@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
sub    $0xfffffffd,%eax
je     1168 <shomdm+0x48>
jmp    1146 <shomdm+0x26>
mov    -0x8(%rbp),%eax
sub    $0xfffffffe,%eax
je     117b <shomdm+0x5b>
jmp    1157 <shomdm+0x37>
mov    -0x8(%rbp),%eax
sub    $0xffffffff,%eax
je     118e <shomdm+0x6e>
jmp    11a1 <shomdm+0x81>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1297 <shomdm+0x177>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1297 <shomdm+0x177>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1297 <shomdm+0x177>
mov    -0x4(%rbp),%ecx
and    $0x4,%ecx
lea    0xeeb(%rip),%rsi
lea    0xee1(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
and    $0x2,%ecx
lea    0xec2(%rip),%rsi
lea    0xeb8(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
and    $0x1,%ecx
lea    0xe99(%rip),%rsi
lea    0xe8f(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
and    $0x8,%ecx
lea    0xe70(%rip),%rsi
lea    0xe66(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
and    $0x10,%ecx
lea    0xe47(%rip),%rsi
lea    0xe3d(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%ecx
and    $0x20,%ecx
lea    0xe1e(%rip),%rsi
lea    0xe14(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shomdm>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <ttgmdm@plt>
cmp    $0xffffffff,%eax
je     1156 <shomdm+0x26>
mov    %eax,%ebx
cmp    $0xfffffffe,%eax
je     115f <shomdm+0x2f>
cmp    $0xfffffffd,%ebx
jne    1170 <shomdm+0x40>
lea    0xfb6(%rip),%rdi
jmp    1166 <shomdm+0x36>
lea    0xf70(%rip),%rdi
jmp    1166 <shomdm+0x36>
lea    0xf82(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <puts@plt>
test   $0x4,%bl
lea    0xeaa(%rip),%r15
lea    0xea0(%rip),%r14
mov    %r14,%rsi
cmove  %r15,%rsi
lea    0xe71(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x2,%bl
mov    %r14,%rsi
cmove  %r15,%rsi
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x1,%bl
mov    %r14,%rsi
cmove  %r15,%rsi
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x8,%bl
mov    %r14,%rsi
cmove  %r15,%rsi
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x10,%bl
mov    %r14,%rsi
cmove  %r15,%rsi
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   $0x20,%bl
cmove  %r15,%r14
lea    0xea8(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"Modem signals unavailable in this version of Kermit\0D\0A\00"
@.str.1 = [35 x i8] c"No modem control for this device\0D\0A\00"
@.str.2 = [28 x i8] c"Modem signals unavailable\0D\0A\00"
@.str.3 = [33 x i8] c" Carrier Detect (CD): %s\0D\0A\00"
@.str.4 = [3 x i8] c"On\00"
@.str.5 = [4 x i8] c"Off\00"
@.str.6 = [33 x i8] c" Dataset Ready (DSR): %s\0D\0A\00"
@.str.7 = [33 x i8] c" Clear To Send (CTS): %s\0D\0A\00"
@.str.8 = [33 x i8] c" Ring Indicator (RI): %s\0D\0A\00"
@.str.9 = [33 x i8] c" Data Terminal Ready (DTR): %s\0D\0A\00"
@.str.10 = [33 x i8] c" Request To Send (RTS): %s\0D\0A\00"
define void @shomdm() {
%1 = alloca i32
%2 = call i32 (...) @ttgmdm()
store i32 %2, i32* %1
%3 = load i32, i32* %1
switch i32 %3, label %10 [
i32 -3, label %4
i32 -2, label %6
i32 -1, label %8
]
4: ; preds = %0
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
br label %47
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %47
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %47
10: ; preds = %0
%11 = load i32, i32* %1
%12 = and i32 %11, 4
%13 = icmp ne i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %1
%18 = and i32 %17, 2
%19 = icmp ne i32 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %21)
%23 = load i32, i32* %1
%24 = and i32 %23, 1
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i64
%27 = select i1 %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %27)
%29 = load i32, i32* %1
%30 = and i32 %29, 8
%31 = icmp ne i32 %30, 0
%32 = zext i1 %31 to i64
%33 = select i1 %31, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %33)
%35 = load i32, i32* %1
%36 = and i32 %35, 16
%37 = icmp ne i32 %36, 0
%38 = zext i1 %37 to i64
%39 = select i1 %37, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %39)
%41 = load i32, i32* %1
%42 = and i32 %41, 32
%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.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0)
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %45)
br label %47
47: ; preds = %10, %8, %6, %4
ret void
}

LLVM IR (-O2):
@.str.3 = [33 x i8] c" Carrier Detect (CD): %s\0D\0A\00"
@.str.4 = [3 x i8] c"On\00"
@.str.5 = [4 x i8] c"Off\00"
@.str.6 = [33 x i8] c" Dataset Ready (DSR): %s\0D\0A\00"
@.str.7 = [33 x i8] c" Clear To Send (CTS): %s\0D\0A\00"
@.str.8 = [33 x i8] c" Ring Indicator (RI): %s\0D\0A\00"
@.str.9 = [33 x i8] c" Data Terminal Ready (DTR): %s\0D\0A\00"
@.str.10 = [33 x i8] c" Request To Send (RTS): %s\0D\0A\00"
@str = [27 x i8] c"Modem signals unavailable\0D\00"
@str.11 = [34 x i8] c"No modem control for this device\0D\00"
@str.12 = [53 x i8] c"Modem signals unavailable in this version of Kermit\0D\00"
define void @shomdm() {
%1 = tail call i32 (...) @ttgmdm()
switch i32 %1, label %8 [
i32 -3, label %2
i32 -2, label %4
i32 -1, label %6
]
2: ; preds = %0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.12, i64 0, i64 0))
br label %33
4: ; preds = %0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.11, i64 0, i64 0))
br label %33
6: ; preds = %0
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %33
8: ; preds = %0
%9 = and i32 %1, 4
%10 = icmp eq i32 %9, 0
%11 = select i1 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = and i32 %1, 2
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i8* %15)
%17 = and i32 %1, 1
%18 = icmp eq i32 %17, 0
%19 = select i1 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %19)
%21 = and i32 %1, 8
%22 = icmp eq i32 %21, 0
%23 = select i1 %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0), i8* %23)
%25 = and i32 %1, 16
%26 = icmp eq i32 %25, 0
%27 = select i1 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.9, i64 0, i64 0), i8* %27)
%29 = and i32 %1, 32
%30 = icmp eq i32 %29, 0
%31 = select i1 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i8* %31)
br label %33
33: ; preds = %8, %6, %4, %2
ret void
}