#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;
struct tm {
  int tm_min;
  scalar_t__ tm_sec;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ usleep(int);
void wait_every(int minute) {
  time_t t;
  struct tm *ptm;
  for (;;) {
    time(&t);
    ptm = gmtime(&t);
    if ((ptm->tm_min % minute) == 0 && ptm->tm_sec == 0)
      break;
    usleep(1000);
  }
  usleep(1000000);
}


x86 assembly (clang, -O0):
<wait_every>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <time@plt>
lea    -0x8(%rbp),%rdi
call   1040 <gmtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
cltd
idivl  -0x4(%rbp)
cmp    $0x0,%edx
jne    1178 <wait_every+0x48>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    1178 <wait_every+0x48>
jmp    1187 <wait_every+0x57>
mov    $0x3e8,%edi
call   1050 <usleep@plt>
jmp    113b <wait_every+0xb>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<wait_every>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0x4(%rsp),%rbx
jmp    114a <wait_every+0x1a>
nopl   0x0(%rax)
mov    $0x3e8,%edi
call   1050 <usleep@plt>
mov    %rbx,%rdi
call   1030 <time@plt>
mov    %rbx,%rdi
call   1040 <gmtime@plt>
mov    %rax,%rcx
mov    (%rax),%eax
cltd
idiv   %ebp
test   %edx,%edx
jne    1140 <wait_every+0x10>
cmpq   $0x0,0x8(%rcx)
jne    1140 <wait_every+0x10>
mov    $0xf4240,%edi
call   1050 <usleep@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i64 }
define void @wait_every(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.tm*
store i32 %0, i32* %2
br label %5
5: ; preds = %20, %1
%6 = call i32 @time(i32* %3)
%7 = call %struct.tm* @gmtime(i32* %3)
store %struct.tm* %7, %struct.tm** %4
%8 = load %struct.tm*, %struct.tm** %4
%9 = getelementptr inbounds %struct.tm, %struct.tm* %8, i32 0, i32 0
%10 = load i32, i32* %9
%11 = load i32, i32* %2
%12 = srem i32 %10, %11
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %5
%15 = load %struct.tm*, %struct.tm** %4
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %22
20: ; preds = %14, %5
%21 = call i32 @usleep(i32 1000)
br label %5
22: ; preds = %19
%23 = call i32 @usleep(i32 1000000)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32, i64 }
define void @wait_every(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
br label %4
4: ; preds = %15, %1
%5 = call i32 @time(i32* %2)
%6 = call %struct.tm* @gmtime(i32* %2)
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
%8 = load i32, i32* %7
%9 = srem i32 %8, %0
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
%13 = load i64, i64* %12
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11, %4
%16 = call i32 @usleep(i32 1000)
br label %4
17: ; preds = %11
%18 = call i32 @usleep(i32 1000000)
ret void
}