#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 tiwlan_signal();
int tiwlan_get_signal(int *strength, char **msg) {
  *strength = tiwlan_signal();
  if (*strength >= 0) {
    if (*strength == 0) {
      *msg = "no signal";
    } else if (*strength < 50) {
      *msg = "excellent";
    } else if (*strength < 75) {
      *msg = "good";
    } else if (*strength < 90) {
      *msg = "fair";
    } else {
      *msg = "weak";
    }
  } else {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<tiwlan_get_signal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1030 <tiwlan_signal@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jl     11de <tiwlan_get_signal+0xce>
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    115c <tiwlan_get_signal+0x4c>
mov    -0x18(%rbp),%rax
lea    0xeac(%rip),%rcx
mov    %rcx,(%rax)
jmp    11d9 <tiwlan_get_signal+0xc9>
mov    -0x10(%rbp),%rax
cmpl   $0x32,(%rax)
jge    117c <tiwlan_get_signal+0x6c>
mov    -0x18(%rbp),%rax
lea    0xe96(%rip),%rcx
mov    %rcx,(%rax)
jmp    11d4 <tiwlan_get_signal+0xc4>
mov    -0x10(%rbp),%rax
cmpl   $0x4b,(%rax)
jge    119c <tiwlan_get_signal+0x8c>
mov    -0x18(%rbp),%rax
lea    0xe80(%rip),%rcx
mov    %rcx,(%rax)
jmp    11cf <tiwlan_get_signal+0xbf>
mov    -0x10(%rbp),%rax
cmpl   $0x5a,(%rax)
jge    11bc <tiwlan_get_signal+0xac>
mov    -0x18(%rbp),%rax
lea    0xe65(%rip),%rcx
mov    %rcx,(%rax)
jmp    11ca <tiwlan_get_signal+0xba>
mov    -0x18(%rbp),%rax
lea    0xe57(%rip),%rcx
mov    %rcx,(%rax)
jmp    11cf <tiwlan_get_signal+0xbf>
jmp    11d4 <tiwlan_get_signal+0xc4>
jmp    11d9 <tiwlan_get_signal+0xc9>
jmp    11ea <tiwlan_get_signal+0xda>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f1 <tiwlan_get_signal+0xe1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tiwlan_get_signal>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <tiwlan_signal@plt>
mov    %eax,(%rbx)
test   %eax,%eax
js     1137 <tiwlan_get_signal+0x27>
je     113e <tiwlan_get_signal+0x2e>
cmp    $0x32,%eax
jae    1147 <tiwlan_get_signal+0x37>
lea    0xed5(%rip),%rax
jmp    116a <tiwlan_get_signal+0x5a>
mov    $0xffffffff,%eax
jmp    116f <tiwlan_get_signal+0x5f>
lea    0xebb(%rip),%rax
jmp    116a <tiwlan_get_signal+0x5a>
cmp    $0x4b,%eax
jae    1155 <tiwlan_get_signal+0x45>
lea    0xec1(%rip),%rax
jmp    116a <tiwlan_get_signal+0x5a>
cmp    $0x5a,%eax
lea    0xeba(%rip),%rcx
lea    0xeb8(%rip),%rax
cmovb  %rcx,%rax
mov    %rax,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"no signal\00"
@.str.1 = [10 x i8] c"excellent\00"
@.str.2 = [5 x i8] c"good\00"
@.str.3 = [5 x i8] c"fair\00"
@.str.4 = [5 x i8] c"weak\00"
define i32 @tiwlan_get_signal(i32* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8**
store i32* %0, i32** %4
store i8** %1, i8*** %5
%6 = call i32 (...) @tiwlan_signal()
%7 = load i32*, i32** %4
store i32 %6, i32* %7
%8 = load i32*, i32** %4
%9 = load i32, i32* %8
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %41
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load i8**, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %16
br label %40
17: ; preds = %11
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = icmp slt i32 %19, 50
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load i8**, i8*** %5
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8** %22
br label %39
23: ; preds = %17
%24 = load i32*, i32** %4
%25 = load i32, i32* %24
%26 = icmp slt i32 %25, 75
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load i8**, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %28
br label %38
29: ; preds = %23
%30 = load i32*, i32** %4
%31 = load i32, i32* %30
%32 = icmp slt i32 %31, 90
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = load i8**, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %34
br label %37
35: ; preds = %29
%36 = load i8**, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %36
br label %37
37: ; preds = %35, %33
br label %38
38: ; preds = %37, %27
br label %39
39: ; preds = %38, %21
br label %40
40: ; preds = %39, %15
br label %42
41: ; preds = %2
store i32 -1, i32* %3
br label %43
42: ; preds = %40
store i32 0, i32* %3
br label %43
43: ; preds = %42, %41
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str = [10 x i8] c"no signal\00"
@.str.1 = [10 x i8] c"excellent\00"
@.str.2 = [5 x i8] c"good\00"
@.str.3 = [5 x i8] c"fair\00"
@.str.4 = [5 x i8] c"weak\00"
define i32 @tiwlan_get_signal(i32* nocapture writeonly %0, i8** nocapture writeonly %1) {
%3 = tail call i32 (...) @tiwlan_signal()
store i32 %3, i32* %0
%4 = icmp sgt i32 %3, -1
br i1 %4, label %5, label %16
5: ; preds = %2
%6 = icmp eq i32 %3, 0
br i1 %6, label %14, label %7
7: ; preds = %5
%8 = icmp ult i32 %3, 50
br i1 %8, label %14, label %9
9: ; preds = %7
%10 = icmp ult i32 %3, 75
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = icmp ult i32 %3, 90
%13 = select i1 %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0)
br label %14
14: ; preds = %11, %9, %7, %5
%15 = phi i8* [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), %5 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %9 ], [ %13, %11 ]
store i8* %15, i8** %1
br label %16
16: ; preds = %14, %2
%17 = phi i32 [ -1, %2 ], [ 0, %14 ]
ret i32 %17
}