#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int s, m, h, p;
  printf("Enter current time (hh. mm. ss): ");
  scanf("%d %d %d", &h, &m, &s);
  printf("Is it 1='am' or 2='pm'? ");
  scanf("%d", &p);
  int as, am, ah;
  printf("Enter addition (hh. mm. ss): ");
  scanf("%d %d %d", &ah, &am, &as);
  int a, x = 0;
  if (s + as >= 60) {
    a = s + as - 60;
    x = 1;
  } else
    a = s + as;
  int b, y = 0;
  if (m + am + x >= 60) {
    b = m + am - 60 + x;
    y = 1;
  } else
    b = m + am + x;
  int c = (h + ah + y) % 12 + 1;
  printf("\nThe time will be: %d. %d. %d", c, b, a);
  if ((h + ah + y) % 24 < 12) {
    if (p == 1)
      p = 2;
    else
      p = 1;
  }
  if (p == 1)
    printf(" am\n\n");
  else
    printf(" pm\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x8(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%eax
add    -0x18(%rbp),%eax
cmp    $0x3c,%eax
jl     11cd <main+0xad>
mov    -0x8(%rbp),%eax
add    -0x18(%rbp),%eax
sub    $0x3c,%eax
mov    %eax,-0x24(%rbp)
movl   $0x1,-0x28(%rbp)
jmp    11d6 <main+0xb6>
mov    -0x8(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0xc(%rbp),%eax
add    -0x1c(%rbp),%eax
add    -0x28(%rbp),%eax
cmp    $0x3c,%eax
jl     120a <main+0xea>
mov    -0xc(%rbp),%eax
add    -0x1c(%rbp),%eax
sub    $0x3c,%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    1216 <main+0xf6>
mov    -0xc(%rbp),%eax
add    -0x1c(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x30(%rbp),%eax
mov    $0xc,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x34(%rbp)
mov    -0x34(%rbp),%esi
mov    -0x2c(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    -0x20(%rbp),%eax
add    -0x30(%rbp),%eax
mov    $0x18,%ecx
cltd
idiv   %ecx
cmp    $0xc,%edx
jge    1280 <main+0x160>
cmpl   $0x1,-0x14(%rbp)
jne    1274 <main+0x154>
movl   $0x2,-0x14(%rbp)
jmp    127b <main+0x15b>
movl   $0x1,-0x14(%rbp)
jmp    1280 <main+0x160>
cmpl   $0x1,-0x14(%rbp)
jne    129d <main+0x17d>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ab <main+0x18b>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed8(%rip),%rbx
lea    0xc(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x1c(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf05(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x14(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x1c(%rsp),%eax
mov    0x14(%rsp),%ecx
lea    (%rcx,%rax,1),%edx
xor    %esi,%esi
cmp    $0x3c,%edx
lea    -0x3c(%rcx,%rax,1),%ecx
cmovl  %edx,%ecx
setge  %sil
mov    0x10(%rsp),%eax
add    0x18(%rsp),%eax
lea    (%rax,%rsi,1),%edi
xor    %ebx,%ebx
cmp    $0x3c,%edi
setge  %bl
lea    -0x3c(%rsi,%rax,1),%edx
cmovl  %edi,%edx
mov    0x8(%rsp),%eax
add    0xc(%rsp),%eax
add    %ebx,%eax
movslq %eax,%rsi
imul   $0x2aaaaaab,%rsi,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
shr    $0x21,%rax
add    %edi,%eax
shl    $0x2,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%esi
add    $0x1,%esi
lea    0xe4f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    0xc(%rsp),%ebx
add    0x8(%rsp),%ebx
movslq %ebx,%rcx
imul   $0x2aaaaaab,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x22,%rax
add    %edx,%eax
shl    $0x3,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ecx
mov    0x4(%rsp),%eax
cmp    $0xb,%ecx
jg     1259 <main+0x129>
cmp    $0x1,%eax
jne    1267 <main+0x137>
movl   $0x2,0x4(%rsp)
jmp    125e <main+0x12e>
cmp    $0x1,%eax
je     126f <main+0x13f>
lea    0xe1b(%rip),%rdi
jmp    1276 <main+0x146>
movl   $0x1,0x4(%rsp)
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [34 x i8] c"Enter current time (hh. mm. ss): \00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [25 x i8] c"Is it 1='am' or 2='pm'? \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [30 x i8] c"Enter addition (hh. mm. ss): \00"
@.str.5 = [30 x i8] c"\0AThe time will be: %d. %d. %d\00"
@.str.6 = [6 x i8] c" am\0A\0A\00"
@.str.7 = [6 x i8] c" pm\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %4, i32* %3, i32* %2)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %8, i32* %7, i32* %6)
store i32 0, i32* %10
%20 = load i32, i32* %2
%21 = load i32, i32* %6
%22 = add nsw i32 %20, %21
%23 = icmp sge i32 %22, 60
br i1 %23, label %24, label %29
24: ; preds = %0
%25 = load i32, i32* %2
%26 = load i32, i32* %6
%27 = add nsw i32 %25, %26
%28 = sub nsw i32 %27, 60
store i32 %28, i32* %9
store i32 1, i32* %10
br label %33
29: ; preds = %0
%30 = load i32, i32* %2
%31 = load i32, i32* %6
%32 = add nsw i32 %30, %31
store i32 %32, i32* %9
br label %33
33: ; preds = %29, %24
store i32 0, i32* %12
%34 = load i32, i32* %3
%35 = load i32, i32* %7
%36 = add nsw i32 %34, %35
%37 = load i32, i32* %10
%38 = add nsw i32 %36, %37
%39 = icmp sge i32 %38, 60
br i1 %39, label %40, label %47
40: ; preds = %33
%41 = load i32, i32* %3
%42 = load i32, i32* %7
%43 = add nsw i32 %41, %42
%44 = sub nsw i32 %43, 60
%45 = load i32, i32* %10
%46 = add nsw i32 %44, %45
store i32 %46, i32* %11
store i32 1, i32* %12
br label %53
47: ; preds = %33
%48 = load i32, i32* %3
%49 = load i32, i32* %7
%50 = add nsw i32 %48, %49
%51 = load i32, i32* %10
%52 = add nsw i32 %50, %51
store i32 %52, i32* %11
br label %53
53: ; preds = %47, %40
%54 = load i32, i32* %4
%55 = load i32, i32* %8
%56 = add nsw i32 %54, %55
%57 = load i32, i32* %12
%58 = add nsw i32 %56, %57
%59 = srem i32 %58, 12
%60 = add nsw i32 %59, 1
store i32 %60, i32* %13
%61 = load i32, i32* %13
%62 = load i32, i32* %11
%63 = load i32, i32* %9
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %61, i32 %62, i32 %63)
%65 = load i32, i32* %4
%66 = load i32, i32* %8
%67 = add nsw i32 %65, %66
%68 = load i32, i32* %12
%69 = add nsw i32 %67, %68
%70 = srem i32 %69, 24
%71 = icmp slt i32 %70, 12
br i1 %71, label %72, label %78
72: ; preds = %53
%73 = load i32, i32* %5
%74 = icmp eq i32 %73, 1
br i1 %74, label %75, label %76
75: ; preds = %72
store i32 2, i32* %5
br label %77
76: ; preds = %72
store i32 1, i32* %5
br label %77
77: ; preds = %76, %75
br label %78
78: ; preds = %77, %53
%79 = load i32, i32* %5
%80 = icmp eq i32 %79, 1
br i1 %80, label %81, label %83
81: ; preds = %78
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %85
83: ; preds = %78
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %85
85: ; preds = %83, %81
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"Enter current time (hh. mm. ss): \00"
@.str.1 = [9 x i8] c"%d %d %d\00"
@.str.2 = [25 x i8] c"Is it 1='am' or 2='pm'? \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [30 x i8] c"Enter addition (hh. mm. ss): \00"
@.str.5 = [30 x i8] c"\0AThe time will be: %d. %d. %d\00"
@str = [5 x i8] c" pm\0A\00"
@str.8 = [5 x i8] c" am\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %1 to i8*
%9 = bitcast i32* %2 to i8*
%10 = bitcast i32* %3 to i8*
%11 = bitcast i32* %4 to i8*
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %2, i32* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%16 = bitcast i32* %5 to i8*
%17 = bitcast i32* %6 to i8*
%18 = bitcast i32* %7 to i8*
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32* %7, i32* %6, i32* %5)
%21 = load i32, i32* %1
%22 = load i32, i32* %5
%23 = add nsw i32 %22, %21
%24 = icmp sgt i32 %23, 59
%25 = add nsw i32 %23, -60
%26 = zext i1 %24 to i32
%27 = select i1 %24, i32 %25, i32 %23
%28 = load i32, i32* %2
%29 = load i32, i32* %6
%30 = add nsw i32 %29, %28
%31 = add i32 %30, %26
%32 = icmp sgt i32 %31, 59
%33 = add i32 %31, -60
%34 = select i1 %32, i32 %33, i32 %31
%35 = zext i1 %32 to i32
%36 = load i32, i32* %3
%37 = load i32, i32* %7
%38 = add nsw i32 %37, %36
%39 = add nsw i32 %38, %35
%40 = srem i32 %39, 12
%41 = add nsw i32 %40, 1
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0), i32 %41, i32 %34, i32 %27)
%43 = load i32, i32* %3
%44 = load i32, i32* %7
%45 = add i32 %43, %35
%46 = add i32 %45, %44
%47 = srem i32 %46, 24
%48 = icmp slt i32 %47, 12
%49 = load i32, i32* %4
%50 = icmp eq i32 %49, 1
br i1 %48, label %51, label %54
51: ; preds = %0
br i1 %50, label %52, label %53
52: ; preds = %51
store i32 2, i32* %4
br label %55
53: ; preds = %51
store i32 1, i32* %4
br label %56
54: ; preds = %0
br i1 %50, label %56, label %55
55: ; preds = %52, %54
br label %56
56: ; preds = %54, %53, %55
%57 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0), %55 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0), %53 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @str.8, i64 0, i64 0), %54 ]
%58 = call i32 @puts(i8* dereferenceable(1) %57)
ret i32 0
}