#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*/ time_t;

/* Variables and functions */
int /*<<< orphan*/ ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ report(int, unsigned int, char *, ...);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int print_state(unsigned char *buf) {
  time_t t = time(NULL);
  int down_speed = 0, up_speed = 0;
  report(2, ((unsigned int)0x00000040), "Modem State\n", ctime(&t));
  report(2, ((unsigned int)0x00000040) | ((unsigned int)0x00000004),
         "c0 12 0007 : ", buf + 0, 1);
  report(2, ((unsigned int)0x00000040) | ((unsigned int)0x00000004),
         "c0 12 000b : ", buf + 1, 8);
  report(2, ((unsigned int)0x00000040) | ((unsigned int)0x00000004),
         "c0 12 000d : ", buf + 9, 4);
  report(2, ((unsigned int)0x00000040) | ((unsigned int)0x00000004),
         "c0 01 000e : ", buf + 13, 1);
  report(2, ((unsigned int)0x00000040) | ((unsigned int)0x00000004),
         "c0 01 000f : ", buf + 14, 1);
  switch (buf[0]) {
  case 0x00:
    report(1, ((unsigned int)0x00000020), "ADSL line is down\n");
    break;
  case 0x08:
    report(1, ((unsigned int)0x00000020), "ADSL line is blocked?\n");
    break;
  case 0x10:
    report(1, ((unsigned int)0x00000020), "ADSL line is synchronising\n");
    break;
  case 0x20:
    down_speed =
        buf[1] | (buf[1 + 1] << 8) | (buf[1 + 2] << 16) | (buf[1 + 3] << 24);
    up_speed = buf[1 + 4] | (buf[1 + 5] << 8) | (buf[1 + 6] << 16) |
               (buf[1 + 7] << 24);
    if (((down_speed & 0x0000ffff) == 0) && ((up_speed & 0x0000ffff) == 0)) {
      down_speed >>= 16;
      up_speed >>= 16;
    }
    report(0, ((unsigned int)0x00000020),
           "ADSL line is up (%d kbit/s down | %d kbit/s up)\n", down_speed,
           up_speed);
    break;
  }
  return (0);
}


x86 assembly (clang, -O0):
<print_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <ctime@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
lea    0xf16(%rip),%rdx
mov    %al,-0x21(%rbp)
mov    $0x2,%edi
mov    %edi,-0x30(%rbp)
mov    $0x40,%esi
call   1050 <report@plt>
mov    -0x30(%rbp),%edi
mov    -0x21(%rbp),%al
mov    -0x8(%rbp),%rcx
lea    0xefd(%rip),%rdx
mov    $0x44,%esi
mov    %esi,-0x2c(%rbp)
mov    $0x1,%r8d
mov    %r8d,-0x28(%rbp)
call   1050 <report@plt>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x21(%rbp),%al
mov    -0x8(%rbp),%rcx
add    $0x1,%rcx
lea    0xedc(%rip),%rdx
mov    $0x8,%r8d
call   1050 <report@plt>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x21(%rbp),%al
mov    -0x8(%rbp),%rcx
add    $0x9,%rcx
lea    0xec7(%rip),%rdx
mov    $0x4,%r8d
call   1050 <report@plt>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%r8d
mov    -0x21(%rbp),%al
mov    -0x8(%rbp),%rcx
add    $0xd,%rcx
lea    0xeae(%rip),%rdx
call   1050 <report@plt>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%r8d
mov    -0x21(%rbp),%al
mov    -0x8(%rbp),%rcx
add    $0xe,%rcx
lea    0xe9b(%rip),%rdx
call   1050 <report@plt>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %rax,-0x20(%rbp)
sub    $0x20,%rax
ja     1367 <print_state+0x237>
mov    -0x20(%rbp),%rax
lea    0xdad(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x1,%edi
mov    $0x20,%esi
lea    0xe6a(%rip),%rdx
mov    $0x0,%al
call   1050 <report@plt>
jmp    1367 <print_state+0x237>
mov    $0x1,%edi
mov    $0x20,%esi
lea    0xe60(%rip),%rdx
mov    $0x0,%al
call   1050 <report@plt>
jmp    1367 <print_state+0x237>
mov    $0x1,%edi
mov    $0x20,%esi
lea    0xe5a(%rip),%rdx
mov    $0x0,%al
call   1050 <report@plt>
jmp    1367 <print_state+0x237>
mov    -0x8(%rbp),%rax
movzbl 0x1(%rax),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x4(%rcx),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0x5(%rax),%eax
mov    -0x8(%rbp),%rcx
movzbl 0x6(%rcx),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x7(%rcx),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x8(%rbp),%rcx
movzbl 0x8(%rcx),%ecx
shl    $0x18,%ecx
or     %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
and    $0xffff,%eax
cmp    $0x0,%eax
jne    134b <print_state+0x21b>
mov    -0x14(%rbp),%eax
and    $0xffff,%eax
cmp    $0x0,%eax
jne    134b <print_state+0x21b>
mov    -0x10(%rbp),%eax
sar    $0x10,%eax
mov    %eax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
sar    $0x10,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x14(%rbp),%r8d
xor    %edi,%edi
mov    $0x20,%esi
lea    0xdbd(%rip),%rdx
mov    $0x0,%al
call   1050 <report@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_state>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xec0(%rip),%rdx
mov    $0x2,%edi
mov    $0x40,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <report@plt>
lea    0xeb3(%rip),%rdx
mov    $0x2,%edi
mov    $0x44,%esi
mov    %rbx,%rcx
mov    $0x1,%r8d
xor    %eax,%eax
call   1050 <report@plt>
lea    0x1(%rbx),%rcx
lea    0xe9c(%rip),%rdx
mov    $0x2,%edi
mov    $0x44,%esi
mov    $0x8,%r8d
xor    %eax,%eax
call   1050 <report@plt>
lea    0x9(%rbx),%rcx
lea    0xe88(%rip),%rdx
mov    $0x2,%edi
mov    $0x44,%esi
mov    $0x4,%r8d
xor    %eax,%eax
call   1050 <report@plt>
lea    0xd(%rbx),%rcx
lea    0xe74(%rip),%rdx
mov    $0x2,%edi
mov    $0x44,%esi
mov    $0x1,%r8d
xor    %eax,%eax
call   1050 <report@plt>
lea    0xe(%rbx),%rcx
lea    0xe60(%rip),%rdx
mov    $0x2,%edi
mov    $0x44,%esi
mov    $0x1,%r8d
xor    %eax,%eax
call   1050 <report@plt>
movzbl (%rbx),%eax
rol    $0x1d,%eax
cmp    $0x4,%eax
ja     12b1 <print_state+0x181>
lea    0xdda(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe31(%rip),%rdx
jmp    1248 <print_state+0x118>
lea    0xe3b(%rip),%rdx
jmp    1248 <print_state+0x118>
lea    0xe49(%rip),%rdx
mov    $0x1,%edi
mov    $0x20,%esi
xor    %eax,%eax
call   1050 <report@plt>
jmp    12b1 <print_state+0x181>
movzwl 0x1(%rbx),%eax
movzbl 0x3(%rbx),%ecx
shl    $0x10,%ecx
or     %eax,%ecx
movzbl 0x4(%rbx),%edx
shl    $0x18,%edx
or     %ecx,%edx
movzwl 0x5(%rbx),%esi
movzbl 0x7(%rbx),%ecx
shl    $0x10,%ecx
or     %esi,%ecx
movzbl 0x8(%rbx),%edi
shl    $0x18,%edi
or     %ecx,%edi
mov    %edx,%ecx
sar    $0x10,%ecx
mov    %edi,%r8d
sar    $0x10,%r8d
or     %esi,%eax
cmovne %edx,%ecx
cmovne %edi,%r8d
lea    0xe0a(%rip),%rdx
xor    %edi,%edi
mov    $0x20,%esi
xor    %eax,%eax
call   1050 <report@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"Modem State\0A\00"
@.str.1 = [14 x i8] c"c0 12 0007 : \00"
@.str.2 = [14 x i8] c"c0 12 000b : \00"
@.str.3 = [14 x i8] c"c0 12 000d : \00"
@.str.4 = [14 x i8] c"c0 01 000e : \00"
@.str.5 = [14 x i8] c"c0 01 000f : \00"
@.str.6 = [19 x i8] c"ADSL line is down\0A\00"
@.str.7 = [23 x i8] c"ADSL line is blocked?\0A\00"
@.str.8 = [28 x i8] c"ADSL line is synchronising\0A\00"
@.str.9 = [49 x i8] c"ADSL line is up (%d kbit/s down | %d kbit/s up)\0A\00"
define i32 @print_state(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = call i32 @time(i32* null)
store i32 %6, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%7 = call i32 @ctime(i32* %3)
%8 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %10, i32 1)
%12 = load i8*, i8** %2
%13 = getelementptr inbounds i8, i8* %12, i64 1
%14 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %13, i32 8)
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 9
%17 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %16, i32 4)
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 13
%20 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %19, i32 1)
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 14
%23 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %22, i32 1)
%24 = load i8*, i8** %2
%25 = getelementptr inbounds i8, i8* %24, i64 0
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
switch i32 %27, label %95 [
i32 0, label %28
i32 8, label %30
i32 16, label %32
i32 32, label %34
]
28: ; preds = %1
%29 = call i32 (i32, i32, i8*, ...) @report(i32 1, i32 32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %95
30: ; preds = %1
%31 = call i32 (i32, i32, i8*, ...) @report(i32 1, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %95
32: ; preds = %1
%33 = call i32 (i32, i32, i8*, ...) @report(i32 1, i32 32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
br label %95
34: ; preds = %1
%35 = load i8*, i8** %2
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = load i8*, i8** %2
%40 = getelementptr inbounds i8, i8* %39, i64 2
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = shl i32 %42, 8
%44 = or i32 %38, %43
%45 = load i8*, i8** %2
%46 = getelementptr inbounds i8, i8* %45, i64 3
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = shl i32 %48, 16
%50 = or i32 %44, %49
%51 = load i8*, i8** %2
%52 = getelementptr inbounds i8, i8* %51, i64 4
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = shl i32 %54, 24
%56 = or i32 %50, %55
store i32 %56, i32* %4
%57 = load i8*, i8** %2
%58 = getelementptr inbounds i8, i8* %57, i64 5
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = load i8*, i8** %2
%62 = getelementptr inbounds i8, i8* %61, i64 6
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = shl i32 %64, 8
%66 = or i32 %60, %65
%67 = load i8*, i8** %2
%68 = getelementptr inbounds i8, i8* %67, i64 7
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = shl i32 %70, 16
%72 = or i32 %66, %71
%73 = load i8*, i8** %2
%74 = getelementptr inbounds i8, i8* %73, i64 8
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = shl i32 %76, 24
%78 = or i32 %72, %77
store i32 %78, i32* %5
%79 = load i32, i32* %4
%80 = and i32 %79, 65535
%81 = icmp eq i32 %80, 0
br i1 %81, label %82, label %91
82: ; preds = %34
%83 = load i32, i32* %5
%84 = and i32 %83, 65535
%85 = icmp eq i32 %84, 0
br i1 %85, label %86, label %91
86: ; preds = %82
%87 = load i32, i32* %4
%88 = ashr i32 %87, 16
store i32 %88, i32* %4
%89 = load i32, i32* %5
%90 = ashr i32 %89, 16
store i32 %90, i32* %5
br label %91
91: ; preds = %86, %82, %34
%92 = load i32, i32* %4
%93 = load i32, i32* %5
%94 = call i32 (i32, i32, i8*, ...) @report(i32 0, i32 32, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0), i32 %92, i32 %93)
br label %95
95: ; preds = %1, %91, %32, %30, %28
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"Modem State\0A\00"
@.str.1 = [14 x i8] c"c0 12 0007 : \00"
@.str.2 = [14 x i8] c"c0 12 000b : \00"
@.str.3 = [14 x i8] c"c0 12 000d : \00"
@.str.4 = [14 x i8] c"c0 01 000e : \00"
@.str.5 = [14 x i8] c"c0 01 000f : \00"
@.str.6 = [19 x i8] c"ADSL line is down\0A\00"
@.str.7 = [23 x i8] c"ADSL line is blocked?\0A\00"
@.str.8 = [28 x i8] c"ADSL line is synchronising\0A\00"
@.str.9 = [49 x i8] c"ADSL line is up (%d kbit/s down | %d kbit/s up)\0A\00"
define i32 @print_state(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %2
%5 = call i32 @ctime(i32* %2)
%6 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 1)
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32 8)
%10 = getelementptr inbounds i8, i8* %0, i64 9
%11 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %10, i32 4)
%12 = getelementptr inbounds i8, i8* %0, i64 13
%13 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %12, i32 1)
%14 = getelementptr inbounds i8, i8* %0, i64 14
%15 = call i32 (i32, i32, i8*, ...) @report(i32 2, i32 68, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i8* %14, i32 1)
%16 = load i8, i8* %0
%17 = zext i8 %16 to i32
%18 = call i32 @llvm.fshl.i32(i32 %17, i32 %17, i32 29)
switch i32 %18, label %69 [
i32 0, label %19
i32 1, label %21
i32 2, label %23
i32 4, label %25
]
19: ; preds = %1
%20 = call i32 (i32, i32, i8*, ...) @report(i32 1, i32 32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
br label %69
21: ; preds = %1
%22 = call i32 (i32, i32, i8*, ...) @report(i32 1, i32 32, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %69
23: ; preds = %1
%24 = call i32 (i32, i32, i8*, ...) @report(i32 1, i32 32, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.8, i64 0, i64 0))
br label %69
25: ; preds = %1
%26 = load i8, i8* %8
%27 = zext i8 %26 to i32
%28 = getelementptr inbounds i8, i8* %0, i64 2
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = shl nuw nsw i32 %30, 8
%32 = or i32 %31, %27
%33 = getelementptr inbounds i8, i8* %0, i64 3
%34 = load i8, i8* %33
%35 = zext i8 %34 to i32
%36 = shl nuw nsw i32 %35, 16
%37 = or i32 %32, %36
%38 = getelementptr inbounds i8, i8* %0, i64 4
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = shl nuw i32 %40, 24
%42 = or i32 %37, %41
%43 = getelementptr inbounds i8, i8* %0, i64 5
%44 = load i8, i8* %43
%45 = zext i8 %44 to i32
%46 = getelementptr inbounds i8, i8* %0, i64 6
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = shl nuw nsw i32 %48, 8
%50 = or i32 %49, %45
%51 = getelementptr inbounds i8, i8* %0, i64 7
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = shl nuw nsw i32 %53, 16
%55 = or i32 %50, %54
%56 = getelementptr inbounds i8, i8* %0, i64 8
%57 = load i8, i8* %56
%58 = zext i8 %57 to i32
%59 = shl nuw i32 %58, 24
%60 = or i32 %55, %59
%61 = icmp eq i32 %32, 0
%62 = icmp eq i32 %50, 0
%63 = select i1 %61, i1 %62, i1 false
%64 = ashr i32 %42, 16
%65 = ashr i32 %60, 16
%66 = select i1 %63, i32 %64, i32 %42
%67 = select i1 %63, i32 %65, i32 %60
%68 = call i32 (i32, i32, i8*, ...) @report(i32 0, i32 32, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0), i32 %66, i32 %67)
br label %69
69: ; preds = %1, %25, %23, %21, %19
ret i32 0
}