#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*/ SIGINT;
int getpid();
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main() {
  printf("My pid is %d\n", getpid());
  int i = 60;
  while (--i) {
    write(1, ".", 1);
    if (i == 55) {
      kill(getpid(), SIGINT);
    }
    sleep(1);
  }
  write(1, "Done!", 5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xe91(%rip),%rdi
call   1050 <printf@plt>
movl   $0x3c,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     11d0 <main+0x80>
mov    $0x1,%edx
lea    0xe75(%rip),%rsi
mov    %edx,%edi
call   1030 <write@plt>
cmpl   $0x37,-0x8(%rbp)
jne    11c1 <main+0x71>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%edi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
call   1060 <kill@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
jmp    117b <main+0x2b>
mov    $0x1,%edi
lea    0xe34(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <getpid@plt>
lea    0xe9f(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
lea    0xe9f(%rip),%rbx
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
xor    %eax,%eax
call   1040 <getpid@plt>
mov    0x2de9(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1060 <kill@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
mov    $0xffffffca,%ebp
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    $0x1,%edi
call   1070 <sleep@plt>
inc    %ebp
jne    1220 <main+0xd0>
lea    0xdc9(%rip),%rsi
mov    $0x1,%edi
mov    $0x5,%edx
call   1030 <write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"My pid is %d\0A\00"
@.str.1 = [2 x i8] c".\00"
@SIGINT = global i32 0
@.str.2 = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @getpid()
%4 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %3)
store i32 60, i32* %2
br label %5
5: ; preds = %17, %0
%6 = load i32, i32* %2
%7 = add nsw i32 %6, -1
store i32 %7, i32* %2
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 55
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = call i32 (...) @getpid()
%15 = load i32, i32* @SIGINT
%16 = call i32 @kill(i32 %14, i32 %15)
br label %17
17: ; preds = %13, %9
%18 = call i32 @sleep(i32 1)
br label %5
19: ; preds = %5
%20 = call i32 @write(i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"My pid is %d\0A\00"
@.str.1 = [2 x i8] c".\00"
@SIGINT = global i32 0
@.str.2 = [6 x i8] c"Done!\00"
define i32 @main() {
%1 = tail call i32 (...) @getpid()
%2 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 %1)
%3 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%4 = tail call i32 @sleep(i32 1)
%5 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%6 = tail call i32 @sleep(i32 1)
%7 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%8 = tail call i32 @sleep(i32 1)
%9 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%10 = tail call i32 @sleep(i32 1)
%11 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%12 = tail call i32 (...) @getpid()
%13 = load i32, i32* @SIGINT
%14 = tail call i32 @kill(i32 %12, i32 %13)
%15 = tail call i32 @sleep(i32 1)
br label %16
16: ; preds = %16, %0
%17 = phi i32 [ 54, %0 ], [ %20, %16 ]
%18 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1)
%19 = tail call i32 @sleep(i32 1)
%20 = add nsw i32 %17, -1
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %16
22: ; preds = %16
%23 = tail call i32 @write(i32 1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 5)
ret i32 0
}