unsigned int ui_timer_next(unsigned int seconds) {
  unsigned int next;
  if (seconds == 0) {
    next = 0;
    goto done;
  }
  if (seconds <= 10) {
    next = 1;
    goto done;
  }
  if (seconds <= 60) {
    next = seconds % 5;
    next = next ? next : 5;
    goto done;
  }
  next = seconds % 10;
  next = next ? next : 10;
done:
  pb_log("%s: %u = %u\n", __func__, seconds, next);
  return next;
}


x86 assembly (clang, -O0):
<ui_timer_next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1131 <ui_timer_next+0x21>
movl   $0x0,-0x8(%rbp)
jmp    11c4 <ui_timer_next+0xb4>
cmpl   $0xa,-0x4(%rbp)
ja     1147 <ui_timer_next+0x37>
movl   $0x1,-0x8(%rbp)
jmp    11c4 <ui_timer_next+0xb4>
cmpl   $0x3c,-0x4(%rbp)
ja     118d <ui_timer_next+0x7d>
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1175 <ui_timer_next+0x65>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    1182 <ui_timer_next+0x72>
mov    $0x5,%eax
mov    %eax,-0xc(%rbp)
jmp    1182 <ui_timer_next+0x72>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11c4 <ui_timer_next+0xb4>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b1 <ui_timer_next+0xa1>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11be <ui_timer_next+0xae>
mov    $0xa,%eax
mov    %eax,-0x10(%rbp)
jmp    11be <ui_timer_next+0xae>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe2f(%rip),%rdi
lea    0xe35(%rip),%rsi
mov    $0x0,%al
call   1030 <pb_log@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ui_timer_next>:
push   %rbx
mov    %edi,%edx
test   %edi,%edi
je     1147 <ui_timer_next+0x37>
mov    $0x1,%ebx
cmp    $0xb,%edx
jb     116b <ui_timer_next+0x5b>
cmp    $0x3c,%edx
ja     114b <ui_timer_next+0x3b>
movzbl %dl,%eax
imul   $0xcd,%eax,%ecx
shr    $0xa,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movzbl %al,%eax
mov    $0x5,%ecx
cmovne %eax,%ecx
movzbl %cl,%ebx
jmp    116b <ui_timer_next+0x5b>
xor    %ebx,%ebx
jmp    116b <ui_timer_next+0x5b>
mov    %edx,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%eax
mov    %edx,%ecx
sub    %eax,%ecx
mov    $0xa,%ebx
cmovne %ecx,%ebx
lea    0xe8e(%rip),%rdi
lea    0xe94(%rip),%rsi
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <pb_log@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%s: %u = %u\0A\00"
@__func__.ui_timer_next = [14 x i8] c"ui_timer_next\00"
define i32 @ui_timer_next(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %3
br label %34
7: ; preds = %1
%8 = load i32, i32* %2
%9 = icmp ule i32 %8, 10
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 1, i32* %3
br label %34
11: ; preds = %7
%12 = load i32, i32* %2
%13 = icmp ule i32 %12, 60
br i1 %13, label %14, label %24
14: ; preds = %11
%15 = load i32, i32* %2
%16 = urem i32 %15, 5
store i32 %16, i32* %3
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = load i32, i32* %3
br label %22
21: ; preds = %14
br label %22
22: ; preds = %21, %19
%23 = phi i32 [ %20, %19 ], [ 5, %21 ]
store i32 %23, i32* %3
br label %34
24: ; preds = %11
%25 = load i32, i32* %2
%26 = urem i32 %25, 10
store i32 %26, i32* %3
%27 = load i32, i32* %3
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %24
%30 = load i32, i32* %3
br label %32
31: ; preds = %24
br label %32
32: ; preds = %31, %29
%33 = phi i32 [ %30, %29 ], [ 10, %31 ]
store i32 %33, i32* %3
br label %34
34: ; preds = %32, %22, %10, %6
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = call i32 (i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @pb_log to i32 (i8*, i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @__func__.ui_timer_next, i64 0, i64 0), i32 %35, i32 %36)
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [13 x i8] c"%s: %u = %u\0A\00"
@__func__.ui_timer_next = [14 x i8] c"ui_timer_next\00"
define i32 @ui_timer_next(i32 %0) {
%2 = icmp eq i32 %0, 0
br i1 %2, label %17, label %3
3: ; preds = %1
%4 = icmp ult i32 %0, 11
br i1 %4, label %17, label %5
5: ; preds = %3
%6 = icmp ult i32 %0, 61
br i1 %6, label %7, label %13
7: ; preds = %5
%8 = trunc i32 %0 to i8
%9 = urem i8 %8, 5
%10 = icmp eq i8 %9, 0
%11 = select i1 %10, i8 5, i8 %9
%12 = zext i8 %11 to i32
br label %17
13: ; preds = %5
%14 = urem i32 %0, 10
%15 = icmp eq i32 %14, 0
%16 = select i1 %15, i32 10, i32 %14
br label %17
17: ; preds = %3, %1, %13, %7
%18 = phi i32 [ %12, %7 ], [ %16, %13 ], [ 0, %1 ], [ 1, %3 ]
%19 = tail call i32 (i8*, i8*, i32, i32, ...) bitcast (i32 (...)* @pb_log to i32 (i8*, i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @__func__.ui_timer_next, i64 0, i64 0), i32 %0, i32 %18)
ret i32 %18
}