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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
call   1030 <puts@plt>
lea    -0x60(%rbp),%rdi
mov    0x2e52(%rip),%rax
mov    (%rax),%edx
mov    $0x51,%esi
call   1060 <fgets@plt>
lea    -0x60(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     11c6 <main+0x56>
mov    -0x68(%rbp),%rax
movb   $0x0,(%rax)
lea    -0x60(%rbp),%rdi
call   1080 <toUpper@plt>
lea    -0x60(%rbp),%rdi
call   1030 <puts@plt>
lea    -0x60(%rbp),%rdi
call   1090 <punctCount@plt>
mov    %eax,%esi
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1070 <digitCount@plt>
mov    %eax,%esi
lea    0xe3e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x51,%esi
call   1060 <fgets@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     11af <main+0x3f>
movb   $0x0,(%rax)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <toUpper@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1090 <punctCount@plt>
lea    0xe44(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <digitCount@plt>
lea    0xe58(%rip),%rdi
mov    %eax,%esi
call   1040 <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"
@.str.2 = [17 x i8] c" and %d digits.\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* @strrchr(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)
%22 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%23 = call i32 @digitCount(i8* %22)
%24 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %23)
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"
@.str.2 = [17 x i8] c" and %d digits.\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* @strrchr(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)
%14 = call i32 @digitCount(i8* %2)
%15 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %14)
ret i32 0
}