#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 u_int;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int ntohl(int);
scalar_t__ snprintf(char *, int, char *, int);
char *dmp_dns_timestr(u_int s) {
  static char buf[64];
  int off = 0;
  buf[0] = '\0';
  s = ntohl(s);
  if (s / (3600 * 24)) {
    off += snprintf(buf + off, sizeof(buf), "%d days", s / (3600 * 24));
    s -= (s / (3600 * 24)) * (3600 * 24);
  }
  if (s / (3600)) {
    off += snprintf(buf + off, sizeof(buf), "%d hours", s / (3600));
    s -= (s / (3600)) * (3600);
  }
  if (s / (60)) {
    off += snprintf(buf + off, sizeof(buf), "%d minutes", s / (60));
    s -= (s / (60)) * (60);
  }
  if (s) {
    off += snprintf(buf + off, sizeof(buf), "%d minutes", s / (60));
  }
  return buf;
}


x86 assembly (clang, -O0):
<dmp_dns_timestr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movb   $0x0,0x2f07(%rip)
mov    -0x4(%rbp),%edi
call   1040 <ntohl@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     11aa <dmp_dns_timestr+0x8a>
movslq -0x8(%rbp),%rax
lea    0x2edd(%rip),%rdi
add    %rax,%rdi
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x40,%esi
lea    0xe81(%rip),%rdx
call   1030 <snprintf@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x15180,%ecx
cltd
idiv   %ecx
imul   $0x15180,%eax,%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     1210 <dmp_dns_timestr+0xf0>
movslq -0x8(%rbp),%rax
lea    0x2e77(%rip),%rdi
add    %rax,%rdi
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x40,%esi
lea    0xe23(%rip),%rdx
call   1030 <snprintf@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xe10,%ecx
cltd
idiv   %ecx
imul   $0xe10,%eax,%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     1273 <dmp_dns_timestr+0x153>
movslq -0x8(%rbp),%rax
lea    0x2e11(%rip),%rdi
add    %rax,%rdi
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x40,%esi
lea    0xdc6(%rip),%rdx
call   1030 <snprintf@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
imul   $0x3c,%eax,%ecx
mov    -0x4(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     12b6 <dmp_dns_timestr+0x196>
movslq -0x8(%rbp),%rax
lea    0x2db8(%rip),%rdi
add    %rax,%rdi
mov    -0x4(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    $0x40,%esi
lea    0xd6d(%rip),%rdx
call   1030 <snprintf@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
lea    0x2d83(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dmp_dns_timestr>:
push   %r15
push   %r14
push   %rbx
movb   $0x0,0x2f14(%rip)
call   1040 <ntohl@plt>
mov    %eax,%r15d
lea    0x1517f(%r15),%eax
cmp    $0x2a2ff,%eax
jae    1147 <dmp_dns_timestr+0x27>
xor    %r14d,%r14d
jmp    118b <dmp_dns_timestr+0x6b>
movslq %r15d,%rax
imul   $0xffffffffc22e4507,%rax,%rbx
shr    $0x20,%rbx
add    %r15d,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0x10,%ebx
add    %eax,%ebx
lea    0x2ed7(%rip),%rdi
lea    0xe90(%rip),%rdx
mov    $0x40,%esi
mov    %ebx,%ecx
call   1030 <snprintf@plt>
mov    %rax,%r14
imul   $0xfffeae80,%ebx,%eax
add    %r15d,%eax
mov    %eax,%r15d
lea    0xe0f(%r15),%eax
cmp    $0x1c1f,%eax
jb     11e3 <dmp_dns_timestr+0xc3>
movslq %r15d,%rax
imul   $0xffffffff91a2b3c5,%rax,%rbx
shr    $0x20,%rbx
add    %r15d,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0xb,%ebx
add    %eax,%ebx
movslq %r14d,%r14
lea    0x2e82(%rip),%rdi
add    %r14,%rdi
lea    0xe40(%rip),%rdx
mov    $0x40,%esi
mov    %ebx,%ecx
call   1030 <snprintf@plt>
add    %eax,%r14d
imul   $0xfffff1f0,%ebx,%eax
add    %r15d,%eax
mov    %eax,%r15d
lea    0x3b(%r15),%eax
cmp    $0x77,%eax
jb     1233 <dmp_dns_timestr+0x113>
movslq %r15d,%rax
imul   $0xffffffff88888889,%rax,%rbx
shr    $0x20,%rbx
add    %r15d,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0x5,%ebx
add    %eax,%ebx
movslq %r14d,%r14
lea    0x2e2f(%rip),%rdi
add    %r14,%rdi
lea    0xdf6(%rip),%rdx
mov    $0x40,%esi
mov    %ebx,%ecx
call   1030 <snprintf@plt>
add    %eax,%r14d
imul   $0xffffffc4,%ebx,%eax
add    %r15d,%eax
mov    %eax,%r15d
test   %r15d,%r15d
je     1271 <dmp_dns_timestr+0x151>
movslq %r14d,%rax
lea    0x2dfe(%rip),%rdi
add    %rax,%rdi
movslq %r15d,%rax
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %r15d,%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
sar    $0x5,%ecx
add    %eax,%ecx
lea    0xdaa(%rip),%rdx
mov    $0x40,%esi
call   1030 <snprintf@plt>
lea    0x2dc8(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@dmp_dns_timestr.buf = internal global [64 x i8] zeroinitializer
@.str = [8 x i8] c"%d days\00"
@.str.1 = [9 x i8] c"%d hours\00"
@.str.2 = [11 x i8] c"%d minutes\00"
define i8* @dmp_dns_timestr(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0)
%4 = load i32, i32* %2
%5 = call i32 @ntohl(i32 %4)
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = sdiv i32 %6, 86400
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %1
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0), i64 %11
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 86400
%15 = call i64 @snprintf(i8* %12, i32 64, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = add nsw i64 %17, %15
%19 = trunc i64 %18 to i32
store i32 %19, i32* %3
%20 = load i32, i32* %2
%21 = sdiv i32 %20, 86400
%22 = mul nsw i32 %21, 86400
%23 = load i32, i32* %2
%24 = sub nsw i32 %23, %22
store i32 %24, i32* %2
br label %25
25: ; preds = %9, %1
%26 = load i32, i32* %2
%27 = sdiv i32 %26, 3600
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %45
29: ; preds = %25
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0), i64 %31
%33 = load i32, i32* %2
%34 = sdiv i32 %33, 3600
%35 = call i64 @snprintf(i8* %32, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = add nsw i64 %37, %35
%39 = trunc i64 %38 to i32
store i32 %39, i32* %3
%40 = load i32, i32* %2
%41 = sdiv i32 %40, 3600
%42 = mul nsw i32 %41, 3600
%43 = load i32, i32* %2
%44 = sub nsw i32 %43, %42
store i32 %44, i32* %2
br label %45
45: ; preds = %29, %25
%46 = load i32, i32* %2
%47 = sdiv i32 %46, 60
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %65
49: ; preds = %45
%50 = load i32, i32* %3
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0), i64 %51
%53 = load i32, i32* %2
%54 = sdiv i32 %53, 60
%55 = call i64 @snprintf(i8* %52, i32 64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %54)
%56 = load i32, i32* %3
%57 = sext i32 %56 to i64
%58 = add nsw i64 %57, %55
%59 = trunc i64 %58 to i32
store i32 %59, i32* %3
%60 = load i32, i32* %2
%61 = sdiv i32 %60, 60
%62 = mul nsw i32 %61, 60
%63 = load i32, i32* %2
%64 = sub nsw i32 %63, %62
store i32 %64, i32* %2
br label %65
65: ; preds = %49, %45
%66 = load i32, i32* %2
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %79
68: ; preds = %65
%69 = load i32, i32* %3
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0), i64 %70
%72 = load i32, i32* %2
%73 = sdiv i32 %72, 60
%74 = call i64 @snprintf(i8* %71, i32 64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %73)
%75 = load i32, i32* %3
%76 = sext i32 %75 to i64
%77 = add nsw i64 %76, %74
%78 = trunc i64 %77 to i32
store i32 %78, i32* %3
br label %79
79: ; preds = %68, %65
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@dmp_dns_timestr.buf = internal global [64 x i8] zeroinitializer
@.str = [8 x i8] c"%d days\00"
@.str.1 = [9 x i8] c"%d hours\00"
@.str.2 = [11 x i8] c"%d minutes\00"
define i8* @dmp_dns_timestr(i32 %0) {
store i8 0, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0)
%2 = tail call i32 @ntohl(i32 %0)
%3 = sdiv i32 %2, 86400
%4 = add i32 %2, 86399
%5 = icmp ult i32 %4, 172799
br i1 %5, label %11, label %6
6: ; preds = %1
%7 = tail call i64 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %3)
%8 = trunc i64 %7 to i32
%9 = mul nsw i32 %3, -86400
%10 = add i32 %9, %2
br label %11
11: ; preds = %6, %1
%12 = phi i32 [ %10, %6 ], [ %2, %1 ]
%13 = phi i32 [ %8, %6 ], [ 0, %1 ]
%14 = sdiv i32 %12, 3600
%15 = add i32 %12, 3599
%16 = icmp ult i32 %15, 7199
br i1 %16, label %25, label %17
17: ; preds = %11
%18 = sext i32 %13 to i64
%19 = getelementptr inbounds [64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 %18
%20 = tail call i64 @snprintf(i8* %19, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%21 = trunc i64 %20 to i32
%22 = add i32 %13, %21
%23 = mul nsw i32 %14, -3600
%24 = add i32 %23, %12
br label %25
25: ; preds = %17, %11
%26 = phi i32 [ %24, %17 ], [ %12, %11 ]
%27 = phi i32 [ %22, %17 ], [ %13, %11 ]
%28 = sdiv i32 %26, 60
%29 = add i32 %26, 59
%30 = icmp ult i32 %29, 119
br i1 %30, label %39, label %31
31: ; preds = %25
%32 = sext i32 %27 to i64
%33 = getelementptr inbounds [64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 %32
%34 = tail call i64 @snprintf(i8* %33, i32 64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%35 = trunc i64 %34 to i32
%36 = add i32 %27, %35
%37 = mul nsw i32 %28, -60
%38 = add i32 %37, %26
br label %39
39: ; preds = %31, %25
%40 = phi i32 [ %38, %31 ], [ %26, %25 ]
%41 = phi i32 [ %36, %31 ], [ %27, %25 ]
%42 = icmp eq i32 %40, 0
br i1 %42, label %48, label %43
43: ; preds = %39
%44 = sext i32 %41 to i64
%45 = getelementptr inbounds [64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 %44
%46 = sdiv i32 %40, 60
%47 = tail call i64 @snprintf(i8* %45, i32 64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %46)
br label %48
48: ; preds = %43, %39
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @dmp_dns_timestr.buf, i64 0, i64 0)
}