#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*/ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
void iw_print_pm_value(char *buffer, int buflen, int value, int flags,
                       int we_version) {
  if (buflen < 25) {
    snprintf(buffer, buflen, "<too big>");
    return;
  }
  buflen -= 25;
  if (flags & 0x0001) {
    strcpy(buffer, " min");
    buffer += 4;
  }
  if (flags & 0x0002) {
    strcpy(buffer, " max");
    buffer += 4;
  }
  if (flags & 0x2000) {
    strcpy(buffer, " timeout:");
    buffer += 9;
  } else {
    if (flags & 0x4000) {
      strcpy(buffer, " saving:");
      buffer += 8;
    } else {
      strcpy(buffer, " period:");
      buffer += 8;
    }
  }
  if (flags & 0x0004) {
    if (we_version < 21)
      value /= 1e6;
    snprintf(buffer, buflen, "%d", value);
  } else {
    if (value >= (int)1e6)
      snprintf(buffer, buflen, "%gs", ((double)value) / 1e6);
    else if (value >= (int)1e3)
      snprintf(buffer, buflen, "%gms", ((double)value) / 1e3);
    else
      snprintf(buffer, buflen, "%dus", value);
  }
}


x86 assembly (clang, -O0):
<iw_print_pm_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
cmpl   $0x19,-0xc(%rbp)
jge    115d <iw_print_pm_value+0x3d>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    0xebf(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    1321 <iw_print_pm_value+0x201>
mov    -0xc(%rbp),%eax
sub    $0x19,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1191 <iw_print_pm_value+0x71>
mov    -0x8(%rbp),%rdi
lea    0xe9a(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     11bc <iw_print_pm_value+0x9c>
mov    -0x8(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x14(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
je     11ee <iw_print_pm_value+0xce>
mov    -0x8(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x9,%rax
mov    %rax,-0x8(%rbp)
jmp    1241 <iw_print_pm_value+0x121>
mov    -0x14(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     1220 <iw_print_pm_value+0x100>
mov    -0x8(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    123c <iw_print_pm_value+0x11c>
mov    -0x8(%rbp),%rdi
lea    0xe0c(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    1241 <iw_print_pm_value+0x121>
mov    -0x14(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
je     128f <iw_print_pm_value+0x16f>
cmpl   $0x15,-0x18(%rbp)
jge    1272 <iw_print_pm_value+0x152>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xda1(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%ecx
lea    0xdbd(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    1321 <iw_print_pm_value+0x201>
cmpl   $0xf4240,-0x10(%rbp)
jl     12c7 <iw_print_pm_value+0x1a7>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xd58(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xd88(%rip),%rdx
mov    $0x1,%al
call   1040 <snprintf@plt>
jmp    131c <iw_print_pm_value+0x1fc>
cmpl   $0x3e8,-0x10(%rbp)
jl     12ff <iw_print_pm_value+0x1df>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xd18(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xd54(%rip),%rdx
mov    $0x1,%al
call   1040 <snprintf@plt>
jmp    1317 <iw_print_pm_value+0x1f7>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%ecx
lea    0xd3c(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
jmp    131c <iw_print_pm_value+0x1fc>
jmp    1321 <iw_print_pm_value+0x201>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iw_print_pm_value>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r12d
mov    %rdi,%rbx
cmp    $0x18,%esi
jg     1158 <iw_print_pm_value+0x38>
lea    0xed3(%rip),%rdx
mov    %rbx,%rdi
mov    %r12d,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <snprintf@plt>
mov    %r8d,%r14d
mov    %ecx,%r13d
mov    %edx,%r15d
test   $0x1,%r13b
je     117a <iw_print_pm_value+0x5a>
lea    0xeac(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0x4,%rbx
test   $0x2,%r13b
je     1193 <iw_print_pm_value+0x73>
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
add    $0x4,%rbx
add    $0xffffffe7,%r12d
test   $0x4000,%r13d
lea    0xe92(%rip),%rax
lea    0xe82(%rip),%rcx
cmove  %rax,%rcx
xor    %ebp,%ebp
test   $0x2000,%r13d
sete   %bpl
lea    0xe60(%rip),%rsi
cmove  %rcx,%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
neg    %rbp
lea    (%rbx,%rbp,1),%rdi
add    $0x9,%rdi
test   $0x4,%r13b
jne    1200 <iw_print_pm_value+0xe0>
cmp    $0xf4240,%r15d
jl     1221 <iw_print_pm_value+0x101>
cvtsi2sd %r15d,%xmm0
divsd  0xe09(%rip),%xmm0
lea    0xe45(%rip),%rdx
jmp    123e <iw_print_pm_value+0x11e>
cmp    $0x14,%r14d
jg     1218 <iw_print_pm_value+0xf8>
cvtsi2sd %r15d,%xmm0
divsd  0xded(%rip),%xmm0
cvttsd2si %xmm0,%r15d
lea    0xe21(%rip),%rdx
jmp    125d <iw_print_pm_value+0x13d>
cmp    $0x3e8,%r15d
jl     1256 <iw_print_pm_value+0x136>
cvtsi2sd %r15d,%xmm0
divsd  0xdd1(%rip),%xmm0
lea    0xe09(%rip),%rdx
mov    %r12d,%esi
mov    $0x1,%al
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <snprintf@plt>
lea    0xdef(%rip),%rdx
mov    %r12d,%esi
mov    %r15d,%ecx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <snprintf@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"<too big>\00"
@.str.1 = [5 x i8] c" min\00"
@.str.2 = [5 x i8] c" max\00"
@.str.3 = [10 x i8] c" timeout:\00"
@.str.4 = [9 x i8] c" saving:\00"
@.str.5 = [9 x i8] c" period:\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [4 x i8] c"%gs\00"
@.str.8 = [5 x i8] c"%gms\00"
@.str.9 = [5 x i8] c"%dus\00"
define void @iw_print_pm_value(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 25
br i1 %12, label %13, label %17
13: ; preds = %5
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %14, i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %105
17: ; preds = %5
%18 = load i32, i32* %7
%19 = sub nsw i32 %18, 25
store i32 %19, i32* %7
%20 = load i32, i32* %9
%21 = and i32 %20, 1
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i8*, i8** %6
%25 = call i32 @strcpy(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = load i8*, i8** %6
%27 = getelementptr inbounds i8, i8* %26, i64 4
store i8* %27, i8** %6
br label %28
28: ; preds = %23, %17
%29 = load i32, i32* %9
%30 = and i32 %29, 2
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %28
%33 = load i8*, i8** %6
%34 = call i32 @strcpy(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%35 = load i8*, i8** %6
%36 = getelementptr inbounds i8, i8* %35, i64 4
store i8* %36, i8** %6
br label %37
37: ; preds = %32, %28
%38 = load i32, i32* %9
%39 = and i32 %38, 8192
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %46
41: ; preds = %37
%42 = load i8*, i8** %6
%43 = call i32 @strcpy(i8* %42, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i64 9
store i8* %45, i8** %6
br label %61
46: ; preds = %37
%47 = load i32, i32* %9
%48 = and i32 %47, 16384
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %46
%51 = load i8*, i8** %6
%52 = call i32 @strcpy(i8* %51, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%53 = load i8*, i8** %6
%54 = getelementptr inbounds i8, i8* %53, i64 8
store i8* %54, i8** %6
br label %60
55: ; preds = %46
%56 = load i8*, i8** %6
%57 = call i32 @strcpy(i8* %56, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%58 = load i8*, i8** %6
%59 = getelementptr inbounds i8, i8* %58, i64 8
store i8* %59, i8** %6
br label %60
60: ; preds = %55, %50
br label %61
61: ; preds = %60, %41
%62 = load i32, i32* %9
%63 = and i32 %62, 4
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %78
65: ; preds = %61
%66 = load i32, i32* %10
%67 = icmp slt i32 %66, 21
br i1 %67, label %68, label %73
68: ; preds = %65
%69 = load i32, i32* %8
%70 = sitofp i32 %69 to double
%71 = fdiv double %70, 1.000000e+06
%72 = fptosi double %71 to i32
store i32 %72, i32* %8
br label %73
73: ; preds = %68, %65
%74 = load i8*, i8** %6
%75 = load i32, i32* %7
%76 = load i32, i32* %8
%77 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %74, i32 %75, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %76)
br label %105
78: ; preds = %61
%79 = load i32, i32* %8
%80 = icmp sge i32 %79, 1000000
br i1 %80, label %81, label %88
81: ; preds = %78
%82 = load i8*, i8** %6
%83 = load i32, i32* %7
%84 = load i32, i32* %8
%85 = sitofp i32 %84 to double
%86 = fdiv double %85, 1.000000e+06
%87 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %82, i32 %83, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %86)
br label %104
88: ; preds = %78
%89 = load i32, i32* %8
%90 = icmp sge i32 %89, 1000
br i1 %90, label %91, label %98
91: ; preds = %88
%92 = load i8*, i8** %6
%93 = load i32, i32* %7
%94 = load i32, i32* %8
%95 = sitofp i32 %94 to double
%96 = fdiv double %95, 1.000000e+03
%97 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %92, i32 %93, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), double %96)
br label %103
98: ; preds = %88
%99 = load i8*, i8** %6
%100 = load i32, i32* %7
%101 = load i32, i32* %8
%102 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %99, i32 %100, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %101)
br label %103
103: ; preds = %98, %91
br label %104
104: ; preds = %103, %81
br label %105
105: ; preds = %13, %104, %73
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"<too big>\00"
@.str.1 = [5 x i8] c" min\00"
@.str.2 = [5 x i8] c" max\00"
@.str.3 = [10 x i8] c" timeout:\00"
@.str.4 = [9 x i8] c" saving:\00"
@.str.5 = [9 x i8] c" period:\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [4 x i8] c"%gs\00"
@.str.8 = [5 x i8] c"%gms\00"
@.str.9 = [5 x i8] c"%dus\00"
define void @iw_print_pm_value(i8* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = icmp slt i32 %1, 25
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %59
9: ; preds = %5
%10 = add nsw i32 %1, -25
%11 = and i32 %3, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = getelementptr inbounds i8, i8* %0, i64 4
br label %16
16: ; preds = %13, %9
%17 = phi i8* [ %15, %13 ], [ %0, %9 ]
%18 = and i32 %3, 2
%19 = icmp eq i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %16
%21 = tail call i32 @strcpy(i8* %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%22 = getelementptr inbounds i8, i8* %17, i64 4
br label %23
23: ; preds = %20, %16
%24 = phi i8* [ %22, %20 ], [ %17, %16 ]
%25 = and i32 %3, 8192
%26 = icmp eq i32 %25, 0
%27 = and i32 %3, 16384
%28 = icmp eq i32 %27, 0
%29 = select i1 %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0)
%30 = select i1 %26, i8* %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0)
%31 = select i1 %26, i64 8, i64 9
%32 = tail call i32 @strcpy(i8* %24, i8* %30)
%33 = getelementptr inbounds i8, i8* %24, i64 %31
%34 = and i32 %3, 4
%35 = icmp eq i32 %34, 0
br i1 %35, label %45, label %36
36: ; preds = %23
%37 = icmp slt i32 %4, 21
br i1 %37, label %38, label %42
38: ; preds = %36
%39 = sitofp i32 %2 to double
%40 = fdiv double %39, 1.000000e+06
%41 = fptosi double %40 to i32
br label %42
42: ; preds = %38, %36
%43 = phi i32 [ %41, %38 ], [ %2, %36 ]
%44 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %33, i32 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %43)
br label %59
45: ; preds = %23
%46 = icmp sgt i32 %2, 999999
br i1 %46, label %47, label %51
47: ; preds = %45
%48 = sitofp i32 %2 to double
%49 = fdiv double %48, 1.000000e+06
%50 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %33, i32 %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), double %49)
br label %59
51: ; preds = %45
%52 = icmp sgt i32 %2, 999
br i1 %52, label %53, label %57
53: ; preds = %51
%54 = sitofp i32 %2 to double
%55 = fdiv double %54, 1.000000e+03
%56 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %33, i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0), double %55)
br label %59
57: ; preds = %51
%58 = tail call i32 (i8*, i32, i8*, ...) @snprintf(i8* %33, i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0), i32 %2)
br label %59
59: ; preds = %47, %57, %53, %7, %42
ret void
}