#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 PunctCount(char *);
int /*<<< orphan*/ ToUpper(char *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ stdin;
char *strchr(char *, char);
int main(void) {
  char line[81];
  char *find;
  puts("Please enter a line:");
  fgets(line, 81, stdin);
  find = strchr(line, '\n');
  if (find) {
    *find = '\0';
  }
  ToUpper(line);
  puts(line);
  printf("That line has %d punctuation characters.\n", PunctCount(line));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1040 <puts@plt>
lea    -0x60(%rbp),%rdi
mov    0x2e62(%rip),%rax
mov    (%rax),%edx
mov    $0x51,%esi
call   1070 <fgets@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     11b6 <main+0x56>
mov    -0x68(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x60(%rbp),%rdi
call   1080 <ToUpper@plt>
lea    -0x60(%rbp),%rdi
call   1040 <puts@plt>
lea    -0x60(%rbp),%rdi
call   1030 <PunctCount@plt>
mov    %eax,%esi
lea    0xe3b(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0xe94(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e70(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x51,%esi
call   1070 <fgets@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
test   %rax,%rax
je     119f <main+0x3f>
movb   $0x0,(%rax)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <ToUpper@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <PunctCount@plt>
lea    0xe54(%rip),%rdi
mov    %eax,%esi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Please enter a line:\00"
@stdin = global i32 0
@.str.1 = [42 x i8] c"That line has %d punctuation characters.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [81 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 81, i32 %6)
%8 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%9 = call i8* @strchr(i8* %8, i8 signext 10)
store i8* %9, i8** %3
%10 = load i8*, i8** %3
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = load i8*, i8** %3
store i8 0, i8* %13
br label %14
14: ; preds = %12, %0
%15 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%16 = call i32 @ToUpper(i8* %15)
%17 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%18 = call i32 @puts(i8* %17)
%19 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%20 = call i32 @PunctCount(i8* %19)
%21 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %20)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Please enter a line:\00"
@stdin = global i32 0
@.str.1 = [42 x i8] c"That line has %d punctuation characters.\0A\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 81, i32 %4)
%6 = call i8* @strchr(i8* %2, i8 signext 10)
%7 = icmp eq i8* %6, null
br i1 %7, label %9, label %8
8: ; preds = %0
store i8 0, i8* %6
br label %9
9: ; preds = %8, %0
%10 = call i32 @ToUpper(i8* %2)
%11 = call i32 @puts(i8* %2)
%12 = call i32 @PunctCount(i8* %2)
%13 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %12)
ret i32 0
}