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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ isHarshad(int);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  int pretty = 0;
  int idx = 0;
  int sample[] = {1,   2,   3,   4,   5,   6,   7,   8,   9,   10,  12,  18,
                  20,  21,  24,  27,  30,  36,  40,  42,  45,  48,  50,  54,
                  60,  63,  70,  72,  80,  81,  84,  90,  100, 102, 108, 110,
                  111, 112, 114, 117, 120, 126, 132, 133, 135, 140, 144, 150,
                  152, 153, 156, 162, 171, 180, 190, 192, 195, 198, 200};
  printf("Display all Harshad numbers between 1 and 200\n\n");
  for (int i = 0; i < 201; ++i) {
    if (isHarshad(i)) {
      assert(sample[idx++] == i);
      printf("%d", i);
      pretty++;
      if (pretty % 5 == 0)
        printf("\n");
      else
        printf("\t");
    }
  }
  printf("\n\n=== END ===\n\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x100(%rbp),%rdi
lea    0xe92(%rip),%rsi
mov    $0xec,%edx
call   1060 <memcpy@plt>
lea    0xf6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x104(%rbp)
cmpl   $0xc9,-0x104(%rbp)
jge    124c <main+0x10c>
mov    -0x104(%rbp),%edi
call   1040 <isHarshad@plt>
cmp    $0x0,%rax
je     1233 <main+0xf3>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0xc(%rbp)
cltq
mov    -0x100(%rbp,%rax,4),%eax
cmp    -0x104(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x104(%rbp),%esi
lea    0xf33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1220 <main+0xe0>
lea    0xf06(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122e <main+0xee>
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0xf3>
jmp    1238 <main+0xf8>
mov    -0x104(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x104(%rbp)
jmp    1190 <main+0x50>
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xf90(%rip),%rdi
call   1040 <puts@plt>
lea    0xe95(%rip),%r14
lea    0xf7a(%rip),%r15
xor    %ebp,%ebp
xor    %r12d,%r12d
xor    %ebx,%ebx
jmp    118b <main+0x3b>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0xc9,%ebp
je     11db <main+0x8b>
mov    %ebp,%edi
call   1060 <isHarshad@plt>
test   %rax,%rax
je     1180 <main+0x30>
movslq %r12d,%rax
add    $0x1,%r12d
xor    %edi,%edi
cmp    (%r14,%rax,4),%ebp
sete   %dil
call   1070 <assert@plt>
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
imul   $0xcccccccd,%ebx,%eax
add    $0x19999999,%eax
cmp    $0x33333333,%eax
mov    $0x9,%edi
adc    $0x0,%edi
call   1030 <putchar@plt>
jmp    1180 <main+0x30>
lea    0xf3c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.sample = [59 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 12, i32 18, i32 20, i32 21, i32 24, i32 27, i32 30, i32 36, i32 40, i32 42, i32 45, i32 48, i32 50, i32 54, i32 60, i32 63, i32 70, i32 72, i32 80, i32 81, i32 84, i32 90, i32 100, i32 102, i32 108, i32 110, i32 111, i32 112, i32 114, i32 117, i32 120, i32 126, i32 132, i32 133, i32 135, i32 140, i32 144, i32 150, i32 152, i32 153, i32 156, i32 162, i32 171, i32 180, i32 190, i32 192, i32 195, i32 198, i32 200]
@.str = [48 x i8] c"Display all Harshad numbers between 1 and 200\0A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [2 x i8] c"\09\00"
@.str.4 = [16 x i8] c"\0A\0A=== END ===\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [59 x i32]
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%6 = bitcast [59 x i32]* %4 to i8*
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %5
br label %8
8: ; preds = %38, %0
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 201
br i1 %10, label %11, label %41
11: ; preds = %8
%12 = load i32, i32* %5
%13 = call i64 @isHarshad(i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %37
15: ; preds = %11
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
%18 = sext i32 %16 to i64
%19 = getelementptr inbounds [59 x i32], [59 x i32]* %4, i64 0, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* %5
%22 = icmp eq i32 %20, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = srem i32 %29, 5
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %15
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
34: ; preds = %15
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %32
br label %37
37: ; preds = %36, %11
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %8
41: ; preds = %8
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.sample = [59 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 12, i32 18, i32 20, i32 21, i32 24, i32 27, i32 30, i32 36, i32 40, i32 42, i32 45, i32 48, i32 50, i32 54, i32 60, i32 63, i32 70, i32 72, i32 80, i32 81, i32 84, i32 90, i32 100, i32 102, i32 108, i32 110, i32 111, i32 112, i32 114, i32 117, i32 120, i32 126, i32 132, i32 133, i32 135, i32 140, i32 144, i32 150, i32 152, i32 153, i32 156, i32 162, i32 171, i32 180, i32 190, i32 192, i32 195, i32 198, i32 200]
@.str.1 = [3 x i8] c"%d\00"
@str = [47 x i8] c"Display all Harshad numbers between 1 and 200\0A\00"
@str.5 = [15 x i8] c"\0A\0A=== END ===\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %4
2: ; preds = %24
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.5, i64 0, i64 0))
ret i32 0
4: ; preds = %0, %24
%5 = phi i32 [ 0, %0 ], [ %27, %24 ]
%6 = phi i32 [ 0, %0 ], [ %26, %24 ]
%7 = phi i32 [ 0, %0 ], [ %25, %24 ]
%8 = tail call i64 @isHarshad(i32 %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %24, label %10
10: ; preds = %4
%11 = add nsw i32 %6, 1
%12 = sext i32 %6 to i64
%13 = getelementptr inbounds [59 x i32], [59 x i32]* @__const.main.sample, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = icmp eq i32 %14, %5
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%19 = add nsw i32 %7, 1
%20 = srem i32 %19, 5
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 10, i32 9
%23 = tail call i32 @putchar(i32 %22)
br label %24
24: ; preds = %10, %4
%25 = phi i32 [ %7, %4 ], [ %19, %10 ]
%26 = phi i32 [ %6, %4 ], [ %11, %10 ]
%27 = add nuw nsw i32 %5, 1
%28 = icmp eq i32 %27, 201
br i1 %28, label %2, label %4
}