#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 */
typedef int /*<<< orphan*/ phone_number;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ memmove(char *, char *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *);
char *strdup(char *);
int strlen(char *);
int main() {
  int i, j;
  char phone_number[128];
  char *username = strdup("448080000105");
  memset(phone_number, 0, sizeof(phone_number));
  for (i = 0, j = 0; username[i]; i++) {
    if (isdigit(username[i])) {
      phone_number[j++] = username[i];
      if (j == sizeof(phone_number) - 1)
        break;
    } else if (username[i] == '*') {
      break;
    };
  };
  free(username);
  if (strlen(phone_number) == 10) {
    memmove(phone_number + 1, phone_number, 10);
    phone_number[0] = '1';
  };
  printf("Test after: %s\n", phone_number);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe77(%rip),%rdi
call   1090 <strdup@plt>
mov    %rax,-0x98(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x98(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1258 <main+0xe8>
mov    -0x98(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     1223 <main+0xb3>
mov    -0x98(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0xc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xc(%rbp)
cltq
mov    %cl,-0x90(%rbp,%rax,1)
movslq -0xc(%rbp),%rax
cmp    $0x7f,%rax
jne    121e <main+0xae>
jmp    1258 <main+0xe8>
jmp    1245 <main+0xd5>
mov    -0x98(%rbp),%rax
movslq -0x8(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
jne    1240 <main+0xd0>
jmp    1258 <main+0xe8>
jmp    1245 <main+0xd5>
jmp    124a <main+0xda>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b6 <main+0x46>
mov    -0x98(%rbp),%rdi
call   1030 <free@plt>
lea    -0x90(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0xa,%eax
jne    129c <main+0x12c>
lea    -0x90(%rbp),%rdi
add    $0x1,%rdi
lea    -0x90(%rbp),%rsi
mov    $0xa,%edx
call   1080 <memmove@plt>
movb   $0x31,-0x90(%rbp)
lea    -0x90(%rbp),%rsi
lea    0xd63(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
lea    0xe7c(%rip),%rdi
call   1090 <strdup@plt>
mov    %rax,%r14
mov    %rsp,%rdi
xor    %ebp,%ebp
xor    %esi,%esi
mov    $0x80,%edx
call   1070 <memset@plt>
mov    (%r14),%r15b
test   %r15b,%r15b
je     11e0 <main+0x70>
mov    %r14,%rbx
add    $0x1,%rbx
jmp    11c3 <main+0x53>
xchg   %ax,%ax
cmp    $0x2a,%r15b
je     11e0 <main+0x70>
movzbl (%rbx),%r15d
add    $0x1,%rbx
test   %r15b,%r15b
je     11e0 <main+0x70>
movsbl %r15b,%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     11b0 <main+0x40>
movslq %ebp,%rax
add    $0x1,%ebp
mov    %r15b,(%rsp,%rax,1)
cmp    $0x7f,%ebp
jne    11b6 <main+0x46>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rsp,%rdi
call   1050 <strlen@plt>
cmp    $0xa,%eax
jne    120b <main+0x9b>
lea    0x1(%rsp),%rdi
mov    %rsp,%rsi
mov    $0xa,%edx
call   1080 <memmove@plt>
movb   $0x31,(%rsp)
lea    0xdfb(%rip),%rdi
mov    %rsp,%rsi
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"448080000105\00"
@.str.1 = [16 x i8] c"Test after: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [128 x i8]
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i8* @strdup(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i8* %6, i8** %5
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 128)
store i32 0, i32* %2
store i32 0, i32* %3
br label %9
9: ; preds = %50, %0
%10 = load i8*, i8** %5
%11 = load i32, i32* %2
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %53
16: ; preds = %9
%17 = load i8*, i8** %5
%18 = load i32, i32* %2
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %39
24: ; preds = %16
%25 = load i8*, i8** %5
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8, i8* %25, i64 %27
%29 = load i8, i8* %28
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
%32 = sext i32 %30 to i64
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %32
store i8 %29, i8* %33
%34 = load i32, i32* %3
%35 = sext i32 %34 to i64
%36 = icmp eq i64 %35, 127
br i1 %36, label %37, label %38
37: ; preds = %24
br label %53
38: ; preds = %24
br label %49
39: ; preds = %16
%40 = load i8*, i8** %5
%41 = load i32, i32* %2
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 42
br i1 %46, label %47, label %48
47: ; preds = %39
br label %53
48: ; preds = %39
br label %49
49: ; preds = %48, %38
br label %50
50: ; preds = %49
%51 = load i32, i32* %2
%52 = add nsw i32 %51, 1
store i32 %52, i32* %2
br label %9
53: ; preds = %47, %37, %9
%54 = load i8*, i8** %5
%55 = call i32 @free(i8* %54)
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%57 = call i32 @strlen(i8* %56)
%58 = icmp eq i32 %57, 10
br i1 %58, label %59, label %65
59: ; preds = %53
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%61 = getelementptr inbounds i8, i8* %60, i64 1
%62 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%63 = call i32 @memmove(i8* %61, i8* %62, i32 10)
%64 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
store i8 49, i8* %64
br label %65
65: ; preds = %59, %53
%66 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%67 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %66)
%68 = load i32, i32* %1
ret i32 %68
}

LLVM IR (-O2):
@.str = [13 x i8] c"448080000105\00"
@.str.1 = [16 x i8] c"Test after: %s\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%3 = tail call dereferenceable_or_null(13) i8* @strdup(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @memset(i8* %2, i32 0, i32 128)
%5 = load i8, i8* %3
%6 = icmp eq i8 %5, 0
br i1 %6, label %26, label %7
7: ; preds = %0, %20
%8 = phi i64 [ %22, %20 ], [ 0, %0 ]
%9 = phi i8 [ %24, %20 ], [ %5, %0 ]
%10 = phi i32 [ %21, %20 ], [ 0, %0 ]
%11 = call i64 @isdigit(i8 signext %9)
%12 = icmp eq i64 %11, 0
br i1 %12, label %18, label %13
13: ; preds = %7
%14 = add nsw i32 %10, 1
%15 = sext i32 %10 to i64
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 %15
store i8 %9, i8* %16
%17 = icmp eq i32 %14, 127
br i1 %17, label %26, label %20
18: ; preds = %7
%19 = icmp eq i8 %9, 42
br i1 %19, label %26, label %20
20: ; preds = %13, %18
%21 = phi i32 [ %14, %13 ], [ %10, %18 ]
%22 = add nuw i64 %8, 1
%23 = getelementptr inbounds i8, i8* %3, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %7
26: ; preds = %20, %13, %18, %0
%27 = call i32 @free(i8* %3)
%28 = call i32 @strlen(i8* %2)
%29 = icmp eq i32 %28, 10
br i1 %29, label %30, label %33
30: ; preds = %26
%31 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 1
%32 = call i32 @memmove(i8* %31, i8* %2, i32 10)
store i8 49, i8* %2
br label %33
33: ; preds = %30, %26
%34 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
}