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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, ...);
void write_time(FILE *file, int rows) {
  int measure = rows / 16;
  int beat = (rows % 16) / 4;
  int row = (rows % 16) % 4;
  fprintf(file, "%i", measure + 1);
  if (beat || row) {
    fprintf(file, ":%i:%i", beat + 1, row);
  }
}


x86 assembly (clang, -O0):
<write_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
add    $0x1,%edx
lea    0xe96(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
cmpl   $0x0,-0x14(%rbp)
jne    1189 <write_time+0x79>
cmpl   $0x0,-0x18(%rbp)
je     11a4 <write_time+0x94>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    -0x18(%rbp),%ecx
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_time>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %rdi,%r14
lea    0xf(%r15),%ebp
test   %esi,%esi
cmovns %esi,%ebp
mov    %ebp,%edx
sar    $0x4,%edx
and    $0xfffffff0,%ebp
mov    %esi,%r12d
sub    %ebp,%r12d
mov    %r12d,%ebx
sar    $0x7,%bl
shr    $0x6,%bl
add    %r12b,%bl
mov    %ebx,%eax
and    $0xfc,%al
sub    %al,%r12b
add    $0x1,%edx
lea    0xeb2(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
neg    %ebp
lea    (%r15,%rbp,1),%eax
add    $0xfffffffc,%eax
cmp    $0xfffffff9,%eax
jb     1175 <write_time+0x65>
test   %r12b,%r12b
jne    1175 <write_time+0x65>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
sar    $0x2,%bl
movsbl %r12b,%ecx
add    $0x1,%bl
movsbl %bl,%edx
lea    0xe77(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%i\00"
@.str.1 = [7 x i8] c":%i:%i\00"
define void @write_time(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = sdiv i32 %8, 16
store i32 %9, i32* %5
%10 = load i32, i32* %4
%11 = srem i32 %10, 16
%12 = sdiv i32 %11, 4
store i32 %12, i32* %6
%13 = load i32, i32* %4
%14 = srem i32 %13, 16
%15 = srem i32 %14, 4
store i32 %15, i32* %7
%16 = load i32*, i32** %3
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
%19 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %2
%23 = load i32, i32* %7
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %22, %2
%26 = load i32*, i32** %3
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
%29 = load i32, i32* %7
%30 = call i32 (i32*, i8*, i32, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %28, i32 %29)
br label %31
31: ; preds = %25, %22
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%i\00"
@.str.1 = [7 x i8] c":%i:%i\00"
define void @write_time(i32* nocapture %0, i32 %1) {
%3 = sdiv i32 %1, 16
%4 = srem i32 %1, 16
%5 = trunc i32 %4 to i8
%6 = srem i8 %5, 4
%7 = sdiv i8 %5, 4
%8 = add nsw i32 %3, 1
%9 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = add nsw i32 %4, -4
%11 = icmp ult i32 %10, -7
%12 = icmp ne i8 %6, 0
%13 = or i1 %11, %12
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = sext i8 %6 to i32
%16 = add nsw i8 %7, 1
%17 = sext i8 %16 to i32
%18 = tail call i32 (i32*, i8*, i32, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %17, i32 %15)
br label %19
19: ; preds = %2, %14
ret void
}