#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ flushStdin();
scalar_t__ malloc(int);
int /*<<< orphan*/ noWhiteSpace(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main() {
  int maxStrLen = 0;
  char *str = NULL;
  char *noSpaceStr = NULL;
  printf("Enter a max string lenght: ");
  scanf("%d", &maxStrLen);
  flushStdin();
  str = (char *)malloc((maxStrLen + 1) * sizeof(char));
  noSpaceStr = (char *)malloc((maxStrLen + 1) * sizeof(char));
  printf("Enter the string to delete whitespace from: ");
  fgets(str, maxStrLen + 1, stdin);
  noWhiteSpace(str, noSpaceStr);
  printf("%s", noSpaceStr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1080 <flushStdin@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%esi
add    $0x1,%esi
mov    0x2df0(%rip),%rax
mov    (%rax),%edx
call   1050 <fgets@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <noWhiteSpace@plt>
mov    -0x18(%rbp),%rsi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
lea    0xe8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
xor    %eax,%eax
call   1080 <flushStdin@plt>
mov    0x4(%rsp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%r14
mov    0x4(%rsp),%edi
add    $0x1,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
add    $0x1,%esi
mov    0x2e1c(%rip),%rax
mov    (%rax),%edx
mov    %r14,%rdi
call   1050 <fgets@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <noWhiteSpace@plt>
lea    0xe64(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [28 x i8] c"Enter a max string lenght: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"Enter the string to delete whitespace from: \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i32 0, i32* %2
store i8* null, i8** %3
store i8* null, i8** %4
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (...) @flushStdin()
%8 = load i32, i32* %2
%9 = add nsw i32 %8, 1
%10 = sext i32 %9 to i64
%11 = mul i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %3
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = mul i64 %17, 1
%19 = trunc i64 %18 to i32
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
store i8* %21, i8** %4
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%23 = load i8*, i8** %3
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
%26 = load i32, i32* @stdin
%27 = call i32 @fgets(i8* %23, i32 %25, i32 %26)
%28 = load i8*, i8** %3
%29 = load i8*, i8** %4
%30 = call i32 @noWhiteSpace(i8* %28, i8* %29)
%31 = load i8*, i8** %4
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"Enter a max string lenght: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [45 x i8] c"Enter the string to delete whitespace from: \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = call i32 (...) @flushStdin()
%6 = load i32, i32* %1
%7 = add nsw i32 %6, 1
%8 = call i64 @malloc(i32 %7)
%9 = inttoptr i64 %8 to i8*
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
%12 = call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* %1
%16 = add nsw i32 %15, 1
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %9, i32 %16, i32 %17)
%19 = call i32 @noWhiteSpace(i8* %9, i8* %13)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %13)
ret i32 0
}