#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*/ assert(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ remove_currency_symbol(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int strlen(char *);
int test_remove_currency_symbol() {
  char original[20], result[20];
  int i;
  printf("test_remove_currency_symbol...");
  sprintf(original, "%s", "$428");
  sprintf(result, "%s", original);
  assert(strlen(original) == strlen(result));
  remove_currency_symbol(original);
  assert(strlen(original) == strlen(result) - 1);
  for (i = 0; i < strlen(original); i++) {
    assert(original[i] == result[i + 1]);
  }
  printf("ok\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_remove_currency_symbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
lea    -0x20(%rbp),%rdi
lea    0xeb0(%rip),%rsi
lea    0xeac(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0x40(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xe95(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x4c(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x20(%rbp),%rdi
call   1050 <remove_currency_symbol@plt>
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
sub    $0x1,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x50(%rbp)
lea    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
cmp    %ecx,%eax
jge    1244 <test_remove_currency_symbol+0xf4>
movslq -0x44(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
mov    -0x44(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movsbl -0x40(%rbp,%rcx,1),%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11f4 <test_remove_currency_symbol+0xa4>
lea    0xddc(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_remove_currency_symbol>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
lea    0xe91(%rip),%rdi
call   1060 <printf@plt>
movl   $0x38323424,(%rsp)
movb   $0x0,0x4(%rsp)
lea    0x20(%rsp),%r14
mov    %rsp,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1070 <remove_currency_symbol@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
add    $0xffffffff,%eax
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    121a <test_remove_currency_symbol+0xba>
xor    %eax,%eax
mov    %rsp,%rbx
nopl   (%rax)
movzbl (%rsp,%rax,1),%ecx
lea    0x1(%rax),%rbp
xor    %edi,%edi
cmp    0x21(%rsp,%rax,1),%cl
sete   %dil
call   1080 <assert@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
movslq %eax,%rcx
mov    %rbp,%rax
cmp    %rcx,%rbp
jl     11f0 <test_remove_currency_symbol+0x90>
lea    0xe03(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"test_remove_currency_symbol...\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [5 x i8] c"$428\00"
@.str.3 = [4 x i8] c"ok\0A\00"
define i32 @test_remove_currency_symbol() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = alloca i32
%4 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%6 = call i32 @sprintf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%9 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = icmp eq i32 %11, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%18 = call i32 @remove_currency_symbol(i8* %17)
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = icmp eq i32 %20, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
store i32 0, i32* %3
br label %27
27: ; preds = %47, %0
%28 = load i32, i32* %3
%29 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = icmp slt i32 %28, %30
br i1 %31, label %32, label %50
32: ; preds = %27
%33 = load i32, i32* %3
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = load i32, i32* %3
%39 = add nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %40
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %37, %43
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
br label %47
47: ; preds = %32
%48 = load i32, i32* %3
%49 = add nsw i32 %48, 1
store i32 %49, i32* %3
br label %27
50: ; preds = %27
%51 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i32 1
}

LLVM IR (-O2):
@.str = [31 x i8] c"test_remove_currency_symbol...\00"
@.str.2 = [5 x i8] c"$428\00"
@str = [3 x i8] c"ok\00"
define i32 @test_remove_currency_symbol() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @strcpy(i8* %4, i8* %3)
%7 = call i32 @strlen(i8* %3)
%8 = call i32 @strlen(i8* %4)
%9 = icmp eq i32 %7, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = call i32 @remove_currency_symbol(i8* %3)
%13 = call i32 @strlen(i8* %3)
%14 = call i32 @strlen(i8* %4)
%15 = add nsw i32 %14, -1
%16 = icmp eq i32 %13, %15
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @strlen(i8* %3)
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %34
21: ; preds = %0, %21
%22 = phi i64 [ %25, %21 ], [ 0, %0 ]
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = add nuw nsw i64 %22, 1
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %24, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = call i32 @strlen(i8* %3)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %25, %32
br i1 %33, label %21, label %34
34: ; preds = %21, %0
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret i32 1
}