#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*/ free(char *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ slog_csoup_format(char *, ...);
int /*<<< orphan*/ slog_csoup_puts(int /*<<< orphan*/, int, int /*<<< orphan*/);
int smm_chdir(char *);
char *smm_cwd_alloc(int /*<<< orphan*/);
int do_smm_chdir(char *path) {
  char *cwd;
  int rc;
  rc = smm_chdir(path);
  cwd = smm_cwd_alloc(0);
  slog_csoup_puts(0, (8 | 0), slog_csoup_format("Enter: %s\n", cwd));
  free(cwd);
  slog_csoup_puts(0, (8 | 0),
                  slog_csoup_format("Press any key to continue ... "));
  getchar();
  slog_csoup_puts(0, (8 | 0), slog_csoup_format("(%d)\n", rc));
  return 0;
}


x86 assembly (clang, -O0):
<do_smm_chdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <smm_chdir@plt>
mov    %eax,-0x14(%rbp)
xor    %edi,%edi
call   1070 <smm_cwd_alloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1080 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1050 <slog_csoup_puts@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1080 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1050 <slog_csoup_puts@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    -0x14(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1080 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1050 <slog_csoup_puts@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_smm_chdir>:
push   %rbp
push   %rbx
push   %rax
call   1040 <smm_chdir@plt>
mov    %eax,%ebp
xor    %edi,%edi
call   1070 <smm_cwd_alloc@plt>
mov    %rax,%rbx
lea    0xe85(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1080 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1050 <slog_csoup_puts@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xe69(%rip),%rdi
xor    %eax,%eax
call   1080 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1050 <slog_csoup_puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xe65(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1080 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1050 <slog_csoup_puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"Enter: %s\0A\00"
@.str.1 = [31 x i8] c"Press any key to continue ... \00"
@.str.2 = [6 x i8] c"(%d)\0A\00"
define i32 @do_smm_chdir(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @smm_chdir(i8* %5)
store i32 %6, i32* %4
%7 = call i8* @smm_cwd_alloc(i32 0)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %9)
%11 = load i8*, i8** %3
%12 = call i32 @free(i8* %11)
%13 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %13)
%15 = call i32 (...) @getchar()
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"Enter: %s\0A\00"
@.str.1 = [31 x i8] c"Press any key to continue ... \00"
@.str.2 = [6 x i8] c"(%d)\0A\00"
define i32 @do_smm_chdir(i8* %0) {
%2 = tail call i32 @smm_chdir(i8* %0)
%3 = tail call i8* @smm_cwd_alloc(i32 0)
%4 = tail call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = tail call i32 @slog_csoup_puts(i32 0, i32 8, i32 %4)
%6 = tail call i32 @free(i8* %3)
%7 = tail call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @slog_csoup_puts(i32 0, i32 8, i32 %7)
%9 = tail call i32 (...) @getchar()
%10 = tail call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %2)
%11 = tail call i32 @slog_csoup_puts(i32 0, i32 8, i32 %10)
ret i32 0
}