#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 */
struct timeval {
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  struct timeval stop, start;
  int flag = 1;
  int div, flagdiv = 0;
  int smallest = 20;
  do {
    smallest += 20;
    if (smallest % 19 == 0) {
      div = 18;
      flagdiv = 1;
      do {
        if (smallest % div != 0) {
          flagdiv = 0;
        } else {
          div--;
        }
      } while (flagdiv == 1 && div > 0);
      if (div == 0) {
        flag = 0;
      }
    }
  } while (flag == 1);
  printf("\nlower divisor = %d", smallest);
  gettimeofday(&stop, NULL);
  printf("took %lu usec\n", stop.tv_usec - start.tv_usec);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x14,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x14,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x13,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11d3 <main+0xb3>
movl   $0x12,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
cltd
idivl  -0x18(%rbp)
cmp    $0x0,%edx
je     118b <main+0x6b>
movl   $0x0,-0x1c(%rbp)
jmp    1194 <main+0x74>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    1199 <main+0x79>
xor    %eax,%eax
cmpl   $0x1,-0x1c(%rbp)
mov    %al,-0x21(%rbp)
jne    11b2 <main+0x92>
cmpl   $0x0,-0x18(%rbp)
setg   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    116f <main+0x4f>
cmpl   $0x0,-0x18(%rbp)
jne    11ce <main+0xae>
movl   $0x0,-0x14(%rbp)
jmp    11d3 <main+0xb3>
jmp    11d8 <main+0xb8>
cmpl   $0x1,-0x14(%rbp)
je     1144 <main+0x24>
mov    -0x20(%rbp),%esi
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    -0x8(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
mov    $0x14,%esi
jmp    1134 <main+0x14>
nopw   0x0(%rax,%rax,1)
test   %ecx,%ecx
je     1168 <main+0x48>
add    $0x14,%esi
imul   $0x286bca1b,%esi,%eax
cmp    $0xd79435e,%eax
ja     1134 <main+0x14>
mov    $0x12,%ecx
nopl   0x0(%rax)
mov    %esi,%eax
cltd
idiv   %ecx
xor    %eax,%eax
test   %edx,%edx
sete   %al
sub    %eax,%ecx
test   %edx,%edx
jne    1130 <main+0x10>
test   %ecx,%ecx
jne    1150 <main+0x30>
jmp    1130 <main+0x10>
push   %rax
lea    0xe90(%rip),%rdi
call   1030 <printf@plt>
mov    %rsp,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [20 x i8] c"\0Alower divisor = %d\00"
@.str.1 = [15 x i8] c"took %lu usec\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timeval
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
store i32 0, i32* %6
store i32 20, i32* %7
br label %8
8: ; preds = %39, %0
%9 = load i32, i32* %7
%10 = add nsw i32 %9, 20
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = srem i32 %11, 19
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %38
14: ; preds = %8
store i32 18, i32* %5
store i32 1, i32* %6
br label %15
15: ; preds = %31, %14
%16 = load i32, i32* %7
%17 = load i32, i32* %5
%18 = srem i32 %16, %17
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 0, i32* %6
br label %24
21: ; preds = %15
%22 = load i32, i32* %5
%23 = add nsw i32 %22, -1
store i32 %23, i32* %5
br label %24
24: ; preds = %21, %20
br label %25
25: ; preds = %24
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, 1
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %5
%30 = icmp sgt i32 %29, 0
br label %31
31: ; preds = %28, %25
%32 = phi i1 [ false, %25 ], [ %30, %28 ]
br i1 %32, label %15, label %33
33: ; preds = %31
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %33
store i32 0, i32* %4
br label %37
37: ; preds = %36, %33
br label %38
38: ; preds = %37, %8
br label %39
39: ; preds = %38
%40 = load i32, i32* %4
%41 = icmp eq i32 %40, 1
br i1 %41, label %8, label %42
42: ; preds = %39
%43 = load i32, i32* %7
%44 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%46 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i32 0, i32 0
%49 = load i32, i32* %48
%50 = sub nsw i32 %47, %49
%51 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %1
ret i32 %52
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [20 x i8] c"\0Alower divisor = %d\00"
@.str.1 = [15 x i8] c"took %lu usec\0A\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = bitcast %struct.timeval* %1 to i8*
br label %3
3: ; preds = %18, %0
%4 = phi i32 [ 20, %0 ], [ %5, %18 ]
%5 = add nuw nsw i32 %4, 20
%6 = urem i32 %5, 19
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %18
8: ; preds = %3, %8
%9 = phi i32 [ %13, %8 ], [ 18, %3 ]
%10 = srem i32 %5, %9
%11 = icmp eq i32 %10, 0
%12 = sext i1 %11 to i32
%13 = add nsw i32 %9, %12
%14 = icmp ne i32 %13, 0
%15 = select i1 %11, i1 %14, i1 false
br i1 %15, label %8, label %16
16: ; preds = %8
%17 = icmp eq i32 %13, 0
br i1 %17, label %19, label %18
18: ; preds = %16, %3
br label %3
19: ; preds = %16
%20 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %5)
%21 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%22 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 undef)
ret i32 0
}